From dbc9a7ad31ca123771db44eea1148dcf54ba992c Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Thu, 15 Dec 2022 08:26:52 +0100 Subject: [PATCH] Add mostly minimal changes in order to compile and run with godot 4 --- SCsub | 24 +- bb_param/bb_aabb.h | 4 +- bb_param/bb_array.h | 4 +- bb_param/bb_basis.h | 4 +- bb_param/bb_bool.h | 4 +- bb_param/bb_byte_array.h | 4 +- bb_param/bb_color.h | 4 +- bb_param/bb_color_array.h | 4 +- bb_param/bb_dictionary.h | 4 +- bb_param/bb_float.h | 4 +- bb_param/bb_int.h | 4 +- bb_param/bb_int_array.h | 4 +- bb_param/bb_node.cpp | 6 +- bb_param/bb_node.h | 6 +- bb_param/bb_param.cpp | 15 +- bb_param/bb_param.h | 8 +- bb_param/bb_plane.h | 4 +- bb_param/bb_quat.h | 4 +- bb_param/bb_real_array.h | 4 +- bb_param/bb_rect2.h | 4 +- bb_param/bb_string.h | 4 +- bb_param/bb_string_array.h | 4 +- bb_param/bb_transform.h | 4 +- bb_param/bb_transform2d.h | 4 +- bb_param/bb_variant.cpp | 6 +- bb_param/bb_variant.h | 6 +- bb_param/bb_vector2.h | 4 +- bb_param/bb_vector2_array.h | 4 +- bb_param/bb_vector3.h | 4 +- bb_param/bb_vector3_array.h | 4 +- blackboard.cpp | 5 +- blackboard.h | 13 +- bt/actions/bt_action.cpp | 2 +- bt/actions/bt_action.h | 4 +- bt/actions/bt_console_print.cpp | 8 +- bt/actions/bt_console_print.h | 16 +- bt/actions/bt_fail.h | 4 +- bt/actions/bt_random_wait.h | 8 +- bt/actions/bt_wait.cpp | 8 +- bt/actions/bt_wait.h | 8 +- bt/actions/bt_wait_ticks.cpp | 6 +- bt/actions/bt_wait_ticks.h | 8 +- bt/behavior_tree.cpp | 13 +- bt/behavior_tree.h | 4 +- bt/bt_player.cpp | 9 +- bt/bt_player.h | 2 +- bt/bt_state.cpp | 4 +- bt/bt_state.h | 10 +- bt/bt_task.cpp | 123 +++--- bt/bt_task.h | 22 +- bt/composites/bt_composite.cpp | 2 +- bt/composites/bt_composite.h | 4 +- bt/composites/bt_dynamic_selector.h | 6 +- bt/composites/bt_dynamic_sequence.h | 6 +- bt/composites/bt_parallel.cpp | 2 +- bt/composites/bt_parallel.h | 6 +- bt/composites/bt_random_selector.h | 6 +- bt/composites/bt_random_sequence.h | 6 +- bt/composites/bt_selector.h | 4 +- bt/composites/bt_sequence.h | 6 +- bt/conditions/bt_condition.cpp | 2 +- bt/conditions/bt_condition.h | 4 +- bt/decorators/bt_always_fail.h | 4 +- bt/decorators/bt_always_succeed.h | 4 +- bt/decorators/bt_cooldown.cpp | 10 +- bt/decorators/bt_cooldown.h | 8 +- bt/decorators/bt_decorator.cpp | 2 +- bt/decorators/bt_decorator.h | 4 +- bt/decorators/bt_delay.cpp | 12 +- bt/decorators/bt_delay.h | 8 +- bt/decorators/bt_for_each.cpp | 10 +- bt/decorators/bt_for_each.h | 8 +- bt/decorators/bt_invert.h | 4 +- bt/decorators/bt_new_scope.cpp | 4 +- bt/decorators/bt_new_scope.h | 6 +- bt/decorators/bt_probability.cpp | 4 +- bt/decorators/bt_probability.h | 6 +- bt/decorators/bt_repeat.cpp | 4 +- bt/decorators/bt_repeat.h | 8 +- bt/decorators/bt_repeat_until_failure.h | 4 +- bt/decorators/bt_repeat_until_success.h | 4 +- bt/decorators/bt_run_limit.h | 6 +- bt/decorators/bt_subtree.cpp | 12 +- bt/decorators/bt_subtree.h | 10 +- bt/decorators/bt_time_limit.cpp | 2 +- bt/decorators/bt_time_limit.h | 8 +- config.py | 4 + editor/limbo_ai_editor_plugin.cpp | 367 +++++++++--------- editor/limbo_ai_editor_plugin.h | 49 +-- icons/{icon_b_t_action.svg => BTAction.svg} | 0 ...n_b_t_always_fail.svg => BTAlwaysFail.svg} | 0 ...always_succeed.svg => BTAlwaysSucceed.svg} | 0 ...icon_b_t_condition.svg => BTCondition.svg} | 0 ...t_console_print.svg => BTConsolePrint.svg} | 0 .../{icon_b_t_cooldown.svg => BTCooldown.svg} | 0 ...icon_b_t_decorator.svg => BTDecorator.svg} | 0 icons/{icon_b_t_delay.svg => BTDelay.svg} | 0 ...mic_selector.svg => BTDynamicSelector.svg} | 0 ...mic_sequence.svg => BTDynamicSequence.svg} | 0 icons/{icon_b_t_fail.svg => BTFail.svg} | 0 .../{icon_b_t_for_each.svg => BTForEach.svg} | 0 icons/{icon_b_t_invert.svg => BTInvert.svg} | 0 ...{icon_b_t_new_scope.svg => BTNewScope.svg} | 0 .../{icon_b_t_parallel.svg => BTParallel.svg} | 0 icons/{icon_b_t_player.svg => BTPlayer.svg} | 0 ..._b_t_probability.svg => BTProbability.svg} | 0 ...selector.svg => BTProbabilitySelector.svg} | 0 ...ndom_selector.svg => BTRandomSelector.svg} | 0 ...ndom_sequence.svg => BTRandomSequence.svg} | 0 ...n_b_t_random_wait.svg => BTRandomWait.svg} | 0 icons/{icon_b_t_repeat.svg => BTRepeat.svg} | 0 ...l_failure.svg => BTRepeatUntilFailure.svg} | 0 ...l_success.svg => BTRepeatUntilSuccess.svg} | 0 ...{icon_b_t_run_limit.svg => BTRunLimit.svg} | 0 .../{icon_b_t_selector.svg => BTSelector.svg} | 0 .../{icon_b_t_sequence.svg => BTSequence.svg} | 0 icons/{icon_b_t_state.svg => BTState.svg} | 0 icons/{icon_b_t_subtree.svg => BTSubtree.svg} | 0 ...con_b_t_time_limit.svg => BTTimeLimit.svg} | 0 icons/{icon_b_t_wait.svg => BTWait.svg} | 0 ...con_b_t_wait_ticks.svg => BTWaitTicks.svg} | 0 ...con_behavior_tree.svg => BehaviorTree.svg} | 0 ...limbo_a_i_editor.svg => LimboAIEditor.svg} | 0 icons/{icon_limbo_h_s_m.svg => LimboHSM.svg} | 0 .../{icon_limbo_state.svg => LimboState.svg} | 0 limbo_hsm.cpp | 14 +- limbo_hsm.h | 15 +- limbo_state.cpp | 40 +- limbo_state.h | 20 +- limbo_string_names.cpp | 2 +- limbo_string_names.h | 7 +- limbo_utility.cpp | 4 +- limbo_utility.h | 3 +- register_types.cpp | 158 ++++---- register_types.h | 6 +- 135 files changed, 702 insertions(+), 633 deletions(-) rename icons/{icon_b_t_action.svg => BTAction.svg} (100%) rename icons/{icon_b_t_always_fail.svg => BTAlwaysFail.svg} (100%) rename icons/{icon_b_t_always_succeed.svg => BTAlwaysSucceed.svg} (100%) rename icons/{icon_b_t_condition.svg => BTCondition.svg} (100%) rename icons/{icon_b_t_console_print.svg => BTConsolePrint.svg} (100%) rename icons/{icon_b_t_cooldown.svg => BTCooldown.svg} (100%) rename icons/{icon_b_t_decorator.svg => BTDecorator.svg} (100%) rename icons/{icon_b_t_delay.svg => BTDelay.svg} (100%) rename icons/{icon_b_t_dynamic_selector.svg => BTDynamicSelector.svg} (100%) rename icons/{icon_b_t_dynamic_sequence.svg => BTDynamicSequence.svg} (100%) rename icons/{icon_b_t_fail.svg => BTFail.svg} (100%) rename icons/{icon_b_t_for_each.svg => BTForEach.svg} (100%) rename icons/{icon_b_t_invert.svg => BTInvert.svg} (100%) rename icons/{icon_b_t_new_scope.svg => BTNewScope.svg} (100%) rename icons/{icon_b_t_parallel.svg => BTParallel.svg} (100%) rename icons/{icon_b_t_player.svg => BTPlayer.svg} (100%) rename icons/{icon_b_t_probability.svg => BTProbability.svg} (100%) rename icons/{icon_b_t_probability_selector.svg => BTProbabilitySelector.svg} (100%) rename icons/{icon_b_t_random_selector.svg => BTRandomSelector.svg} (100%) rename icons/{icon_b_t_random_sequence.svg => BTRandomSequence.svg} (100%) rename icons/{icon_b_t_random_wait.svg => BTRandomWait.svg} (100%) rename icons/{icon_b_t_repeat.svg => BTRepeat.svg} (100%) rename icons/{icon_b_t_repeat_until_failure.svg => BTRepeatUntilFailure.svg} (100%) rename icons/{icon_b_t_repeat_until_success.svg => BTRepeatUntilSuccess.svg} (100%) rename icons/{icon_b_t_run_limit.svg => BTRunLimit.svg} (100%) rename icons/{icon_b_t_selector.svg => BTSelector.svg} (100%) rename icons/{icon_b_t_sequence.svg => BTSequence.svg} (100%) rename icons/{icon_b_t_state.svg => BTState.svg} (100%) rename icons/{icon_b_t_subtree.svg => BTSubtree.svg} (100%) rename icons/{icon_b_t_time_limit.svg => BTTimeLimit.svg} (100%) rename icons/{icon_b_t_wait.svg => BTWait.svg} (100%) rename icons/{icon_b_t_wait_ticks.svg => BTWaitTicks.svg} (100%) rename icons/{icon_behavior_tree.svg => BehaviorTree.svg} (100%) rename icons/{icon_limbo_a_i_editor.svg => LimboAIEditor.svg} (100%) rename icons/{icon_limbo_h_s_m.svg => LimboHSM.svg} (100%) rename icons/{icon_limbo_state.svg => LimboState.svg} (100%) diff --git a/SCsub b/SCsub index 66a7e5c..3c14de0 100644 --- a/SCsub +++ b/SCsub @@ -1,12 +1,16 @@ -# SCsub +#!/usr/bin/env python -Import('env') +Import("env") +Import("env_modules") -env.add_source_files(env.modules_sources, "*.cpp") -env.add_source_files(env.modules_sources, "bt/*.cpp") -env.add_source_files(env.modules_sources, "bt/composites/*.cpp") -env.add_source_files(env.modules_sources, "bt/actions/*.cpp") -env.add_source_files(env.modules_sources, "bt/decorators/*.cpp") -env.add_source_files(env.modules_sources, "bt/conditions/*.cpp") -env.add_source_files(env.modules_sources, "editor/*.cpp") -env.add_source_files(env.modules_sources, "bb_param/*.cpp") +module_env = env.Clone() + +module_env.add_source_files(env.modules_sources, "*.cpp") +module_env.add_source_files(env.modules_sources, "bt/*.cpp") +module_env.add_source_files(env.modules_sources, "bt/composites/*.cpp") +module_env.add_source_files(env.modules_sources, "bt/actions/*.cpp") +module_env.add_source_files(env.modules_sources, "bt/decorators/*.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") diff --git a/bb_param/bb_aabb.h b/bb_param/bb_aabb.h index 4e8dbf4..2017225 100644 --- a/bb_param/bb_aabb.h +++ b/bb_param/bb_aabb.h @@ -4,13 +4,13 @@ #define BB_AABB_H #include "bb_param.h" -#include "core/object.h" +#include "core/object/object.h" class BBAabb : public BBParam { GDCLASS(BBAabb, BBParam); protected: - virtual Variant::Type get_type() const { return Variant::AABB; } + virtual Variant::Type get_type() const override { return Variant::AABB; } }; #endif // BB_AABB_H \ No newline at end of file diff --git a/bb_param/bb_array.h b/bb_param/bb_array.h index 61acb88..1198b88 100644 --- a/bb_param/bb_array.h +++ b/bb_param/bb_array.h @@ -4,13 +4,13 @@ #define BB_ARRAY_H #include "bb_param.h" -#include "core/object.h" +#include "core/object/object.h" class BBArray : public BBParam { GDCLASS(BBArray, BBParam); protected: - virtual Variant::Type get_type() const { return Variant::ARRAY; } + virtual Variant::Type get_type() const override { return Variant::ARRAY; } }; #endif // BB_ARRAY_H \ No newline at end of file diff --git a/bb_param/bb_basis.h b/bb_param/bb_basis.h index 235be0e..f0bf997 100644 --- a/bb_param/bb_basis.h +++ b/bb_param/bb_basis.h @@ -4,13 +4,13 @@ #define BB_BASIS_H #include "bb_param.h" -#include "core/object.h" +#include "core/object/object.h" class BBBasis : public BBParam { GDCLASS(BBBasis, BBParam); protected: - virtual Variant::Type get_type() const { return Variant::BASIS; } + virtual Variant::Type get_type() const override { return Variant::BASIS; } }; #endif // BB_BASIS_H \ No newline at end of file diff --git a/bb_param/bb_bool.h b/bb_param/bb_bool.h index 46e45c9..6cd3381 100644 --- a/bb_param/bb_bool.h +++ b/bb_param/bb_bool.h @@ -4,13 +4,13 @@ #define BB_BOOL_H #include "bb_param.h" -#include "core/object.h" +#include "core/object/object.h" class BBBool : public BBParam { GDCLASS(BBBool, BBParam); protected: - virtual Variant::Type get_type() const { return Variant::BOOL; } + virtual Variant::Type get_type() const override { return Variant::BOOL; } }; #endif // BB_BOOL_H \ No newline at end of file diff --git a/bb_param/bb_byte_array.h b/bb_param/bb_byte_array.h index 2d1d104..c2abfb2 100644 --- a/bb_param/bb_byte_array.h +++ b/bb_param/bb_byte_array.h @@ -4,13 +4,13 @@ #define BB_BYTE_ARRAY_H #include "bb_param.h" -#include "core/object.h" +#include "core/object/object.h" class BBByteArray : public BBParam { GDCLASS(BBByteArray, BBParam); 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 \ No newline at end of file diff --git a/bb_param/bb_color.h b/bb_param/bb_color.h index 2d4a3cf..3db96b8 100644 --- a/bb_param/bb_color.h +++ b/bb_param/bb_color.h @@ -4,13 +4,13 @@ #define BB_COLOR_H #include "bb_param.h" -#include "core/object.h" +#include "core/object/object.h" class BBColor : public BBParam { GDCLASS(BBColor, BBParam); protected: - virtual Variant::Type get_type() const { return Variant::COLOR; } + virtual Variant::Type get_type() const override { return Variant::COLOR; } }; #endif // BB_COLOR_H \ No newline at end of file diff --git a/bb_param/bb_color_array.h b/bb_param/bb_color_array.h index 47c9b78..c3f5c7f 100644 --- a/bb_param/bb_color_array.h +++ b/bb_param/bb_color_array.h @@ -4,13 +4,13 @@ #define BB_COLOR_ARRAY_H #include "bb_param.h" -#include "core/object.h" +#include "core/object/object.h" class BBColorArray : public BBParam { GDCLASS(BBColorArray, BBParam); 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 \ No newline at end of file diff --git a/bb_param/bb_dictionary.h b/bb_param/bb_dictionary.h index 12b9939..7328aea 100644 --- a/bb_param/bb_dictionary.h +++ b/bb_param/bb_dictionary.h @@ -4,13 +4,13 @@ #define BB_DICTIONARY_H #include "bb_param.h" -#include "core/object.h" +#include "core/object/object.h" class BBDictionary : public BBParam { GDCLASS(BBDictionary, BBParam); protected: - virtual Variant::Type get_type() const { return Variant::DICTIONARY; } + virtual Variant::Type get_type() const override { return Variant::DICTIONARY; } }; #endif // BB_DICTIONARY_H \ No newline at end of file diff --git a/bb_param/bb_float.h b/bb_param/bb_float.h index 28f6842..2c6cfb3 100644 --- a/bb_param/bb_float.h +++ b/bb_param/bb_float.h @@ -4,13 +4,13 @@ #define BB_FLOAT_H #include "bb_param.h" -#include "core/object.h" +#include "core/object/object.h" class BBFloat : public BBParam { GDCLASS(BBFloat, BBParam); protected: - virtual Variant::Type get_type() const { return Variant::REAL; } + virtual Variant::Type get_type() const override { return Variant::FLOAT; } }; #endif // BB_FLOAT_H \ No newline at end of file diff --git a/bb_param/bb_int.h b/bb_param/bb_int.h index 8e0529e..ee90afb 100644 --- a/bb_param/bb_int.h +++ b/bb_param/bb_int.h @@ -4,13 +4,13 @@ #define BB_INT_H #include "bb_param.h" -#include "core/object.h" +#include "core/object/object.h" class BBInt : public BBParam { GDCLASS(BBInt, BBParam); protected: - virtual Variant::Type get_type() const { return Variant::INT; } + virtual Variant::Type get_type() const override { return Variant::INT; } }; #endif // BB_INT_H \ No newline at end of file diff --git a/bb_param/bb_int_array.h b/bb_param/bb_int_array.h index ccb41c0..089c85b 100644 --- a/bb_param/bb_int_array.h +++ b/bb_param/bb_int_array.h @@ -4,13 +4,13 @@ #define BB_INT_ARRAY_H #include "bb_param.h" -#include "core/object.h" +#include "core/object/object.h" class BBIntArray : public BBParam { GDCLASS(BBIntArray, BBParam); 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 \ No newline at end of file diff --git a/bb_param/bb_node.cpp b/bb_param/bb_node.cpp index 113e2f9..9aeaace 100644 --- a/bb_param/bb_node.cpp +++ b/bb_param/bb_node.cpp @@ -1,8 +1,8 @@ /* bb_node.cpp */ #include "bb_node.h" -#include "core/error_macros.h" -#include "core/variant.h" +#include "core/error/error_macros.h" +#include "core/variant/variant.h" #include "scene/main/node.h" Variant BBNode::get_value(Object *p_agent, const Ref &p_blackboard, const Variant &p_default) { @@ -21,7 +21,7 @@ Variant BBNode::get_value(Object *p_agent, const Ref &p_blackboard, ERR_FAIL_COND_V_MSG(agent == nullptr, Variant(), "BBNode: p_agent must be a Node."); return agent->get_node(val); } else { - Node *node = val; + Node *node = Object::cast_to(val); if (unlikely(node == nullptr && val.get_type() != Variant::NIL)) { WARN_PRINT("BBNode: Unexpected variant type of a blackboard variable."); return p_default; diff --git a/bb_param/bb_node.h b/bb_param/bb_node.h index cf8ae19..d2ba1b6 100644 --- a/bb_param/bb_node.h +++ b/bb_param/bb_node.h @@ -4,16 +4,16 @@ #define BB_NODE_H #include "bb_param.h" -#include "core/object.h" +#include "core/object/object.h" class BBNode : public BBParam { GDCLASS(BBNode, BBParam); protected: - virtual Variant::Type get_type() const { return Variant::NODE_PATH; } + virtual Variant::Type get_type() const override { return Variant::NODE_PATH; } public: - virtual Variant get_value(Object *p_agent, const Ref &p_blackboard, const Variant &p_default = Variant()); + virtual Variant get_value(Object *p_agent, const Ref &p_blackboard, const Variant &p_default = Variant()) override; }; #endif // BB_NODE_H \ No newline at end of file diff --git a/bb_param/bb_param.cpp b/bb_param/bb_param.cpp index 241874a..de8f23c 100644 --- a/bb_param/bb_param.cpp +++ b/bb_param/bb_param.cpp @@ -1,25 +1,26 @@ /* bb_param.cpp */ #include "bb_param.h" -#include "core/class_db.h" -#include "core/error_macros.h" -#include "core/object.h" -#include "core/variant.h" +#include "core/core_bind.h" +#include "core/error/error_macros.h" +#include "core/object/class_db.h" +#include "core/object/object.h" +#include "core/variant/variant.h" #include "modules/limboai/limbo_utility.h" VARIANT_ENUM_CAST(BBParam::ValueSource); void BBParam::set_value_source(ValueSource p_value) { value_source = p_value; - property_list_changed_notify(); + notify_property_list_changed(); _update_name(); emit_changed(); } Variant BBParam::get_saved_value() { if (saved_value.get_type() != get_type()) { - Variant::CallError err; - saved_value = Variant::construct(get_type(), nullptr, 0, err); + Callable::CallError err; + Variant::construct(get_type(), saved_value, nullptr, 0, err); } return saved_value; } diff --git a/bb_param/bb_param.h b/bb_param/bb_param.h index 48bad4a..7719ea0 100644 --- a/bb_param/bb_param.h +++ b/bb_param/bb_param.h @@ -3,10 +3,10 @@ #ifndef BB_PARAM_H #define BB_PARAM_H -#include "core/object.h" -#include "core/resource.h" +#include "core/io/resource.h" +#include "core/object/object.h" #include "core/typedefs.h" -#include "core/variant.h" +#include "core/variant/variant.h" #include "modules/limboai/blackboard.h" #include "modules/limboai/limbo_utility.h" @@ -45,7 +45,7 @@ public: void set_variable(const String &p_value); String get_variable() const { return variable; } - virtual String to_string(); + virtual String to_string() override; virtual Variant get_value(Object *p_agent, const Ref &p_blackboard, const Variant &p_default = Variant()); diff --git a/bb_param/bb_plane.h b/bb_param/bb_plane.h index dd8d9cd..9dfb543 100644 --- a/bb_param/bb_plane.h +++ b/bb_param/bb_plane.h @@ -4,13 +4,13 @@ #define BB_PLANE_H #include "bb_param.h" -#include "core/object.h" +#include "core/object/object.h" class BBPlane : public BBParam { GDCLASS(BBPlane, BBParam); protected: - virtual Variant::Type get_type() const { return Variant::PLANE; } + virtual Variant::Type get_type() const override { return Variant::PLANE; } }; #endif // BB_PLANE_H \ No newline at end of file diff --git a/bb_param/bb_quat.h b/bb_param/bb_quat.h index 6d18164..83dd778 100644 --- a/bb_param/bb_quat.h +++ b/bb_param/bb_quat.h @@ -4,13 +4,13 @@ #define BB_QUAT_H #include "bb_param.h" -#include "core/object.h" +#include "core/object/object.h" class BBQuat : public BBParam { GDCLASS(BBQuat, BBParam); protected: - virtual Variant::Type get_type() const { return Variant::QUAT; } + virtual Variant::Type get_type() const override { return Variant::QUATERNION; } }; #endif // BB_QUAT_H \ No newline at end of file diff --git a/bb_param/bb_real_array.h b/bb_param/bb_real_array.h index 81147a6..b956beb 100644 --- a/bb_param/bb_real_array.h +++ b/bb_param/bb_real_array.h @@ -4,13 +4,13 @@ #define BB_REAL_ARRAY_H #include "bb_param.h" -#include "core/object.h" +#include "core/object/object.h" class BBRealArray : public BBParam { GDCLASS(BBRealArray, BBParam); 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 \ No newline at end of file diff --git a/bb_param/bb_rect2.h b/bb_param/bb_rect2.h index 4fa8d40..0cd1c98 100644 --- a/bb_param/bb_rect2.h +++ b/bb_param/bb_rect2.h @@ -4,13 +4,13 @@ #define BB_RECT2_H #include "bb_param.h" -#include "core/object.h" +#include "core/object/object.h" class BBRect2 : public BBParam { GDCLASS(BBRect2, BBParam); protected: - virtual Variant::Type get_type() const { return Variant::RECT2; } + virtual Variant::Type get_type() const override { return Variant::RECT2; } }; #endif // BB_RECT2_H \ No newline at end of file diff --git a/bb_param/bb_string.h b/bb_param/bb_string.h index 249fe83..7fb4b51 100644 --- a/bb_param/bb_string.h +++ b/bb_param/bb_string.h @@ -4,13 +4,13 @@ #define BB_STRING_H #include "bb_param.h" -#include "core/object.h" +#include "core/object/object.h" class BBString : public BBParam { GDCLASS(BBString, BBParam); protected: - virtual Variant::Type get_type() const { return Variant::STRING; } + virtual Variant::Type get_type() const override { return Variant::STRING; } }; #endif // BB_STRING_H \ No newline at end of file diff --git a/bb_param/bb_string_array.h b/bb_param/bb_string_array.h index 985ddff..66e6087 100644 --- a/bb_param/bb_string_array.h +++ b/bb_param/bb_string_array.h @@ -4,13 +4,13 @@ #define BB_STRING_ARRAY_H #include "bb_param.h" -#include "core/object.h" +#include "core/object/object.h" class BBStringArray : public BBParam { GDCLASS(BBStringArray, BBParam); 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 \ No newline at end of file diff --git a/bb_param/bb_transform.h b/bb_param/bb_transform.h index 4080277..4fa680b 100644 --- a/bb_param/bb_transform.h +++ b/bb_param/bb_transform.h @@ -4,13 +4,13 @@ #define BB_TRANSFORM_H #include "bb_param.h" -#include "core/object.h" +#include "core/object/object.h" class BBTransform : public BBParam { GDCLASS(BBTransform, BBParam); protected: - virtual Variant::Type get_type() const { return Variant::TRANSFORM; } + virtual Variant::Type get_type() const override { return Variant::TRANSFORM3D; } }; #endif // BB_TRANSFORM_H \ No newline at end of file diff --git a/bb_param/bb_transform2d.h b/bb_param/bb_transform2d.h index fcfa3b7..c414522 100644 --- a/bb_param/bb_transform2d.h +++ b/bb_param/bb_transform2d.h @@ -4,13 +4,13 @@ #define BB_TRANSFORM2D_H #include "bb_param.h" -#include "core/object.h" +#include "core/object/object.h" class BBTransform2D : public BBParam { GDCLASS(BBTransform2D, BBParam); protected: - virtual Variant::Type get_type() const { return Variant::TRANSFORM2D; } + virtual Variant::Type get_type() const override { return Variant::TRANSFORM2D; } }; #endif // BB_TRANSFORM2D_H \ No newline at end of file diff --git a/bb_param/bb_variant.cpp b/bb_param/bb_variant.cpp index e9ca51d..ef8d2df 100644 --- a/bb_param/bb_variant.cpp +++ b/bb_param/bb_variant.cpp @@ -1,12 +1,12 @@ /* bb_variant.cpp */ #include "bb_variant.h" -#include "core/object.h" -#include "core/variant.h" +#include "core/object/object.h" +#include "core/variant/variant.h" void BBVariant::set_type(Variant::Type p_type) { type = p_type; - property_list_changed_notify(); + notify_property_list_changed(); emit_changed(); } diff --git a/bb_param/bb_variant.h b/bb_param/bb_variant.h index 45fe747..3a8b4ec 100644 --- a/bb_param/bb_variant.h +++ b/bb_param/bb_variant.h @@ -4,8 +4,8 @@ #define BB_VARIANT_H #include "bb_param.h" -#include "core/object.h" -#include "core/variant.h" +#include "core/object/object.h" +#include "core/variant/variant.h" class BBVariant : public BBParam { GDCLASS(BBVariant, BBParam); @@ -16,7 +16,7 @@ private: protected: 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); public: diff --git a/bb_param/bb_vector2.h b/bb_param/bb_vector2.h index cf16a5d..9c0279f 100644 --- a/bb_param/bb_vector2.h +++ b/bb_param/bb_vector2.h @@ -4,13 +4,13 @@ #define BB_VECTOR2_H #include "bb_param.h" -#include "core/object.h" +#include "core/object/object.h" class BBVector2 : public BBParam { GDCLASS(BBVector2, BBParam); protected: - virtual Variant::Type get_type() const { return Variant::VECTOR2; } + virtual Variant::Type get_type() const override { return Variant::VECTOR2; } }; #endif // BB_VECTOR2_H \ No newline at end of file diff --git a/bb_param/bb_vector2_array.h b/bb_param/bb_vector2_array.h index b8e8f5e..c422950 100644 --- a/bb_param/bb_vector2_array.h +++ b/bb_param/bb_vector2_array.h @@ -4,13 +4,13 @@ #define BB_VECTOR2_ARRAY_H #include "bb_param.h" -#include "core/object.h" +#include "core/object/object.h" class BBVector2Array : public BBParam { GDCLASS(BBVector2Array, BBParam); 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 \ No newline at end of file diff --git a/bb_param/bb_vector3.h b/bb_param/bb_vector3.h index dfb91c0..1f3cf6b 100644 --- a/bb_param/bb_vector3.h +++ b/bb_param/bb_vector3.h @@ -4,13 +4,13 @@ #define BB_VECTOR3_H #include "bb_param.h" -#include "core/object.h" +#include "core/object/object.h" class BBVector3 : public BBParam { GDCLASS(BBVector3, BBParam); protected: - virtual Variant::Type get_type() const { return Variant::VECTOR3; } + virtual Variant::Type get_type() const override { return Variant::VECTOR3; } }; #endif // BB_VECTOR3_H \ No newline at end of file diff --git a/bb_param/bb_vector3_array.h b/bb_param/bb_vector3_array.h index e5c2143..a7d37bb 100644 --- a/bb_param/bb_vector3_array.h +++ b/bb_param/bb_vector3_array.h @@ -4,13 +4,13 @@ #define BB_VECTOR3_ARRAY_H #include "bb_param.h" -#include "core/object.h" +#include "core/object/object.h" class BBVector3Array : public BBParam { GDCLASS(BBVector3Array, BBParam); 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 \ No newline at end of file diff --git a/blackboard.cpp b/blackboard.cpp index 6f44d9e..faac7ef 100644 --- a/blackboard.cpp +++ b/blackboard.cpp @@ -1,10 +1,9 @@ /* blackboard.cpp */ #include "blackboard.h" -#include "core/error_macros.h" -#include "core/variant.h" +#include "core/error/error_macros.h" +#include "core/variant/variant.h" #include "scene/main/node.h" -#include Ref Blackboard::top() const { Ref bb(this); diff --git a/blackboard.h b/blackboard.h index 4289f94..322dd15 100644 --- a/blackboard.h +++ b/blackboard.h @@ -3,13 +3,14 @@ #ifndef BLACKBOARD_H #define BLACKBOARD_H -#include "core/dictionary.h" -#include "core/object.h" -#include "core/reference.h" -#include "core/variant.h" +#include "core/object/object.h" +#include "core/object/ref_counted.h" +#include "core/variant/dictionary.h" +#include "core/variant/variant.h" +#include "scene/main/node.h" -class Blackboard : public Reference { - GDCLASS(Blackboard, Reference); +class Blackboard : public RefCounted { + GDCLASS(Blackboard, RefCounted); private: Dictionary data; diff --git a/bt/actions/bt_action.cpp b/bt/actions/bt_action.cpp index 9175dda..2034160 100644 --- a/bt/actions/bt_action.cpp +++ b/bt/actions/bt_action.cpp @@ -4,7 +4,7 @@ String BTAction::get_configuration_warning() const { String warning = BTTask::get_configuration_warning(); - if (!warning.empty()) { + if (!warning.is_empty()) { warning += "\n"; } if (get_child_count() != 0) { diff --git a/bt/actions/bt_action.h b/bt/actions/bt_action.h index 57bfd97..3004ee6 100644 --- a/bt/actions/bt_action.h +++ b/bt/actions/bt_action.h @@ -4,13 +4,13 @@ #define BT_ACTION_H #include "../bt_task.h" -#include "core/object.h" +#include "core/object/object.h" class BTAction : public BTTask { GDCLASS(BTAction, BTTask); public: - virtual String get_configuration_warning() const; + virtual String get_configuration_warning() const override; }; #endif // BT_ACTION_H \ No newline at end of file diff --git a/bt/actions/bt_console_print.cpp b/bt/actions/bt_console_print.cpp index ac08542..33a91a9 100644 --- a/bt/actions/bt_console_print.cpp +++ b/bt/actions/bt_console_print.cpp @@ -1,8 +1,8 @@ /* bt_console_print.cpp */ #include "bt_console_print.h" -#include "core/object.h" -#include "core/print_string.h" +#include "core/object/object.h" +#include "core/string/print_string.h" #include "modules/limboai/bt/actions/bt_action.h" String BTConsolePrint::_generate_name() const { @@ -54,7 +54,7 @@ int BTConsolePrint::_tick(float p_delta) { String BTConsolePrint::get_configuration_warning() const { String warning = BTAction::get_configuration_warning(); - if (!warning.empty()) { + if (!warning.is_empty()) { warning += "\n"; } 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); 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"); } \ No newline at end of file diff --git a/bt/actions/bt_console_print.h b/bt/actions/bt_console_print.h index 6a21475..bdf165c 100644 --- a/bt/actions/bt_console_print.h +++ b/bt/actions/bt_console_print.h @@ -4,21 +4,21 @@ #define BT_CONSOLE_PRINT_H #include "bt_action.h" -#include "core/object.h" -#include "core/variant.h" +#include "core/object/object.h" +#include "core/variant/variant.h" class BTConsolePrint : public BTAction { GDCLASS(BTConsolePrint, BTAction); private: String text; - PoolStringArray format_var_args; + PackedStringArray format_var_args; protected: static void _bind_methods(); - virtual String _generate_name() const; - virtual int _tick(float p_delta); + virtual String _generate_name() const override; + virtual int _tick(float p_delta) override; public: void set_text(String p_value) { @@ -27,13 +27,13 @@ public: } 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; 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 \ No newline at end of file diff --git a/bt/actions/bt_fail.h b/bt/actions/bt_fail.h index 88689b6..20f27fc 100644 --- a/bt/actions/bt_fail.h +++ b/bt/actions/bt_fail.h @@ -4,13 +4,13 @@ #define BT_FAIL_H #include "bt_action.h" -#include "core/object.h" +#include "core/object/object.h" class BTFail : public BTAction { GDCLASS(BTFail, BTAction); protected: - virtual int _tick(float p_delta); + virtual int _tick(float p_delta) override; }; #endif // BT_FAIL_H \ No newline at end of file diff --git a/bt/actions/bt_random_wait.h b/bt/actions/bt_random_wait.h index 9311e07..3ee457d 100644 --- a/bt/actions/bt_random_wait.h +++ b/bt/actions/bt_random_wait.h @@ -4,7 +4,7 @@ #define BT_RANDOM_WAIT_H #include "bt_action.h" -#include "core/object.h" +#include "core/object/object.h" class BTRandomWait : public BTAction { GDCLASS(BTRandomWait, BTAction); @@ -18,9 +18,9 @@ private: protected: static void _bind_methods(); - virtual String _generate_name() const; - virtual void _enter(); - virtual int _tick(float p_delta); + virtual String _generate_name() const override; + virtual void _enter() override; + virtual int _tick(float p_delta) override; public: void set_duration_min_max(Vector2 p_value) { diff --git a/bt/actions/bt_wait.cpp b/bt/actions/bt_wait.cpp index 73c64fc..59b0d7b 100644 --- a/bt/actions/bt_wait.cpp +++ b/bt/actions/bt_wait.cpp @@ -1,9 +1,9 @@ /* bt_wait.cpp */ #include "bt_wait.h" -#include "core/class_db.h" -#include "core/object.h" -#include "core/variant.h" +#include "core/object/class_db.h" +#include "core/object/object.h" +#include "core/variant/variant.h" String BTWait::_generate_name() const { 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("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"); } diff --git a/bt/actions/bt_wait.h b/bt/actions/bt_wait.h index aadff9a..a426037 100644 --- a/bt/actions/bt_wait.h +++ b/bt/actions/bt_wait.h @@ -4,7 +4,7 @@ #define BT_WAIT_H #include "bt_action.h" -#include "core/object.h" +#include "core/object/object.h" class BTWait : public BTAction { GDCLASS(BTWait, BTAction); @@ -17,9 +17,9 @@ private: protected: static void _bind_methods(); - virtual String _generate_name() const; - virtual void _enter(); - virtual int _tick(float p_delta); + virtual String _generate_name() const override; + virtual void _enter() override; + virtual int _tick(float p_delta) override; public: void set_duration(float p_value) { diff --git a/bt/actions/bt_wait_ticks.cpp b/bt/actions/bt_wait_ticks.cpp index 099cec0..fdd564d 100644 --- a/bt/actions/bt_wait_ticks.cpp +++ b/bt/actions/bt_wait_ticks.cpp @@ -1,9 +1,9 @@ /* bt_wait_ticks.cpp */ #include "bt_wait_ticks.h" -#include "core/class_db.h" -#include "core/object.h" -#include "core/variant.h" +#include "core/object/class_db.h" +#include "core/object/object.h" +#include "core/variant/variant.h" String BTWaitTicks::_generate_name() const { return vformat("WaitTicks x%d", num_ticks); diff --git a/bt/actions/bt_wait_ticks.h b/bt/actions/bt_wait_ticks.h index 3d6aa9a..1ba2e8e 100644 --- a/bt/actions/bt_wait_ticks.h +++ b/bt/actions/bt_wait_ticks.h @@ -4,7 +4,7 @@ #define BT_WAIT_TICKS_H #include "bt_action.h" -#include "core/object.h" +#include "core/object/object.h" class BTWaitTicks : public BTAction { GDCLASS(BTWaitTicks, BTAction); @@ -17,9 +17,9 @@ private: protected: static void _bind_methods(); - virtual String _generate_name() const; - virtual void _enter(); - virtual int _tick(float p_delta); + virtual String _generate_name() const override; + virtual void _enter() override; + virtual int _tick(float p_delta) override; public: void set_num_ticks(int p_value) { diff --git a/bt/behavior_tree.cpp b/bt/behavior_tree.cpp index 6482da7..421a57b 100644 --- a/bt/behavior_tree.cpp +++ b/bt/behavior_tree.cpp @@ -1,12 +1,11 @@ /* behavior_tree.cpp */ #include "behavior_tree.h" -#include "core/class_db.h" -#include "core/error_macros.h" -#include "core/list.h" -#include "core/object.h" -#include "core/variant.h" -#include +#include "core/error/error_macros.h" +#include "core/object/class_db.h" +#include "core/object/object.h" +#include "core/templates/list.h" +#include "core/variant/variant.h" void BehaviorTree::init() { List stack; @@ -17,7 +16,7 @@ void BehaviorTree::init() { stack.push_back(task->get_child(i).ptr()); } task = nullptr; - if (!stack.empty()) { + if (!stack.is_empty()) { task = stack.front()->get(); stack.pop_front(); } diff --git a/bt/behavior_tree.h b/bt/behavior_tree.h index 72003e5..1bba891 100644 --- a/bt/behavior_tree.h +++ b/bt/behavior_tree.h @@ -4,8 +4,8 @@ #define BEHAVIOR_TREE_H #include "bt_task.h" -#include "core/object.h" -#include "core/resource.h" +#include "core/io/resource.h" +#include "core/object/object.h" #include "modules/limboai/blackboard.h" class BehaviorTree : public Resource { diff --git a/bt/bt_player.cpp b/bt/bt_player.cpp index 3940d11..ee55626 100644 --- a/bt/bt_player.cpp +++ b/bt/bt_player.cpp @@ -4,14 +4,13 @@ #include "../limbo_string_names.h" #include "bt_task.h" -#include "core/class_db.h" -#include "core/engine.h" +#include "core/config/engine.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/variant.h" +#include "core/variant/variant.h" #include "modules/limboai/blackboard.h" -#include VARIANT_ENUM_CAST(BTPlayer::UpdateMode); diff --git a/bt/bt_player.h b/bt/bt_player.h index b361dc1..46e4062 100644 --- a/bt/bt_player.h +++ b/bt/bt_player.h @@ -5,7 +5,7 @@ #include "behavior_tree.h" #include "bt_task.h" -#include "core/object.h" +#include "core/object/object.h" #include "modules/limboai/blackboard.h" #include "scene/main/node.h" diff --git a/bt/bt_state.cpp b/bt/bt_state.cpp index 556d467..746c8d0 100644 --- a/bt/bt_state.cpp +++ b/bt/bt_state.cpp @@ -1,8 +1,8 @@ /* bt_state.cpp */ #include "bt_state.h" -#include "core/class_db.h" -#include "core/variant.h" +#include "core/object/class_db.h" +#include "core/variant/variant.h" #include "modules/limboai/bt/bt_task.h" #include "modules/limboai/limbo_state.h" diff --git a/bt/bt_state.h b/bt/bt_state.h index e944ad9..51fc677 100644 --- a/bt/bt_state.h +++ b/bt/bt_state.h @@ -3,7 +3,7 @@ #ifndef 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/bt_task.h" #include "modules/limboai/limbo_state.h" @@ -20,10 +20,10 @@ private: protected: static void _bind_methods(); - virtual void _setup(); - virtual void _enter() {} - virtual void _exit(); - virtual void _update(float p_delta); + virtual void _setup() override; + virtual void _enter() override {} + virtual void _exit() override; + virtual void _update(float p_delta) override; public: void set_behavior_tree(const Ref &p_value) { behavior_tree = p_value; } diff --git a/bt/bt_task.cpp b/bt/bt_task.cpp index 3fad3f6..6b4a434 100644 --- a/bt/bt_task.cpp +++ b/bt/bt_task.cpp @@ -2,16 +2,18 @@ #include "bt_task.h" -#include "core/class_db.h" -#include "core/error_macros.h" -#include "core/object.h" -#include "core/script_language.h" -#include "core/variant.h" -#include "editor/editor_node.h" +#include "core/error/error_macros.h" +#include "core/io/resource.h" +#include "core/object/class_db.h" +#include "core/object/object.h" +#include "core/object/ref_counted.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/limbo_string_names.h" #include "modules/limboai/limbo_utility.h" -#include String BTTask::_generate_name() const { if (get_script_instance()) { @@ -20,7 +22,7 @@ String BTTask::_generate_name() const { return get_script_instance()->call(LimboStringNames::get_singleton()->_generate_name); } String name = get_script_instance()->get_script()->get_path(); - if (!name.empty()) { + if (!name.is_empty()) { // Generate name based on script file name = name.get_basename().get_file().trim_prefix("BT"); return name; @@ -53,7 +55,7 @@ void BTTask::_set_children(Array p_children) { } String BTTask::get_task_name() const { - if (custom_name.empty()) { + if (custom_name.is_empty()) { return _generate_name(); } return custom_name; @@ -82,12 +84,16 @@ void BTTask::initialize(Object *p_agent, const Ref &p_blackboard) { for (int i = 0; i < children.size(); i++) { get_child(i)->initialize(p_agent, p_blackboard); } - if (get_script_instance() && - get_script_instance()->has_method(LimboStringNames::get_singleton()->_setup)) { - get_script_instance()->call(LimboStringNames::get_singleton()->_setup); - } else { + + if (!GDVIRTUAL_CALL(_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::clone() const { @@ -104,7 +110,7 @@ Ref BTTask::clone() const { // Make BBParam properties unique. List props; inst->get_property_list(&props); - Map duplicates; + HashMap, Ref> duplicates; for (List::Element *E = props.front(); E; E = E->next()) { if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) { continue; @@ -112,10 +118,10 @@ Ref BTTask::clone() const { Variant v = inst->get(E->get().name); - if (v.is_ref()) { - REF ref = v; + if (v.is_ref_counted()) { + Ref ref = v; if (ref.is_valid()) { - RES res = ref; + Ref res = ref; if (res.is_valid() && res->is_class("BBParam")) { if (!duplicates.has(res)) { duplicates[res] = res->duplicate(); @@ -132,31 +138,40 @@ Ref BTTask::clone() const { int BTTask::execute(float p_delta) { if (status != RUNNING) { - 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 { + if (!GDVIRTUAL_CALL(_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() && - // 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 { + if (!GDVIRTUAL_CALL(_tick, p_delta, status)) { 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 (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 { + if (!GDVIRTUAL_CALL(_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; } @@ -166,13 +181,16 @@ void BTTask::cancel() { get_child(i)->cancel(); } if (status == RUNNING) { - 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 { + if (!GDVIRTUAL_CALL(_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; } @@ -208,7 +226,7 @@ void BTTask::remove_child(Ref p_child) { if (idx == -1) { ERR_FAIL_MSG("p_child not found!"); } else { - children.remove(idx); + children.remove_at(idx); p_child->parent = nullptr; emit_changed(); } @@ -216,7 +234,7 @@ void BTTask::remove_child(Ref p_child) { void BTTask::remove_child_at_index(int p_idx) { ERR_FAIL_INDEX(p_idx, get_child_count()); - children.remove(p_idx); + children.remove_at(p_idx); } bool BTTask::has_child(const Ref &p_child) const { @@ -250,10 +268,13 @@ Ref BTTask::next_sibling() const { String BTTask::get_configuration_warning() const { String 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); - } + + GDVIRTUAL_CALL(_get_configuration_warning, 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; } @@ -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, "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::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"); // Virtual methods. + // TODO: Remove if unneeded. ClassDB::bind_method(D_METHOD("_setup"), &BTTask::_setup); - BIND_VMETHOD(MethodInfo("_setup")); ClassDB::bind_method(D_METHOD("_enter"), &BTTask::_enter); - BIND_VMETHOD(MethodInfo("_enter")) ClassDB::bind_method(D_METHOD("_exit"), &BTTask::_exit); - BIND_VMETHOD(MethodInfo("_exit")); 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); - BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::STRING, ""), "_generate_name")); 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. ClassDB::bind_method(D_METHOD("is_root"), &BTTask::is_root); diff --git a/bt/bt_task.h b/bt/bt_task.h index 983af51..070f821 100644 --- a/bt/bt_task.h +++ b/bt/bt_task.h @@ -3,13 +3,13 @@ #ifndef BTTASK_H #define BTTASK_H -#include "core/array.h" -#include "core/dictionary.h" -#include "core/object.h" -#include "core/reference.h" -#include "core/resource.h" -#include "core/ustring.h" -#include "core/vector.h" +#include "core/io/resource.h" +#include "core/object/object.h" +#include "core/object/ref_counted.h" +#include "core/string/ustring.h" +#include "core/templates/vector.h" +#include "core/variant/array.h" +#include "core/variant/dictionary.h" #include "modules/limboai/blackboard.h" #include "scene/resources/texture.h" @@ -46,6 +46,13 @@ protected: virtual void _exit() {} 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: Object *get_agent() const { return agent; } void set_agent(Object *p_agent) { agent = p_agent; } @@ -60,6 +67,7 @@ public: virtual Ref clone() const; virtual void initialize(Object *p_agent, const Ref &p_blackboard); + int execute(float p_delta); void cancel(); Ref get_child(int p_idx) const; diff --git a/bt/composites/bt_composite.cpp b/bt/composites/bt_composite.cpp index 2325ebf..b1ef2b5 100644 --- a/bt/composites/bt_composite.cpp +++ b/bt/composites/bt_composite.cpp @@ -4,7 +4,7 @@ String BTComposite::get_configuration_warning() const { String warning = BTTask::get_configuration_warning(); - if (!warning.empty()) { + if (!warning.is_empty()) { warning += "\n"; } if (get_child_count() < 1) { diff --git a/bt/composites/bt_composite.h b/bt/composites/bt_composite.h index d892223..3628cf3 100644 --- a/bt/composites/bt_composite.h +++ b/bt/composites/bt_composite.h @@ -4,13 +4,13 @@ #define BT_COMPOSITE_H #include "../bt_task.h" -#include "core/object.h" +#include "core/object/object.h" class BTComposite : public BTTask { GDCLASS(BTComposite, BTTask); public: - virtual String get_configuration_warning() const; + virtual String get_configuration_warning() const override; }; #endif // BT_COMPOSITE_H \ No newline at end of file diff --git a/bt/composites/bt_dynamic_selector.h b/bt/composites/bt_dynamic_selector.h index 1375929..059e755 100644 --- a/bt/composites/bt_dynamic_selector.h +++ b/bt/composites/bt_dynamic_selector.h @@ -4,7 +4,7 @@ #define BT_DYNAMIC_SELECTOR_H #include "bt_composite.h" -#include "core/object.h" +#include "core/object/object.h" class BTDynamicSelector : public BTComposite { GDCLASS(BTDynamicSelector, BTComposite); @@ -13,8 +13,8 @@ private: int last_running_idx = 0; protected: - virtual void _enter(); - virtual int _tick(float p_delta); + virtual void _enter() override; + virtual int _tick(float p_delta) override; }; #endif // BT_DYNAMIC_SELECTOR_H \ No newline at end of file diff --git a/bt/composites/bt_dynamic_sequence.h b/bt/composites/bt_dynamic_sequence.h index a1a627d..66999f7 100644 --- a/bt/composites/bt_dynamic_sequence.h +++ b/bt/composites/bt_dynamic_sequence.h @@ -4,7 +4,7 @@ #define BT_DYNAMIC_SEQUENCE_H #include "bt_composite.h" -#include "core/object.h" +#include "core/object/object.h" class BTDynamicSequence : public BTComposite { GDCLASS(BTDynamicSequence, BTComposite); @@ -13,8 +13,8 @@ private: int last_running_idx = 0; protected: - virtual void _enter(); - virtual int _tick(float p_delta); + virtual void _enter() override; + virtual int _tick(float p_delta) override; }; #endif // BT_DYNAMIC_SEQUENCE_H \ No newline at end of file diff --git a/bt/composites/bt_parallel.cpp b/bt/composites/bt_parallel.cpp index 7a991a6..19bb4b5 100644 --- a/bt/composites/bt_parallel.cpp +++ b/bt/composites/bt_parallel.cpp @@ -1,7 +1,7 @@ /* bt_parallel.cpp */ #include "bt_parallel.h" -#include "core/class_db.h" +#include "core/object/class_db.h" void BTParallel::_enter() { for (int i = 0; i < get_child_count(); i++) { diff --git a/bt/composites/bt_parallel.h b/bt/composites/bt_parallel.h index 1fa2ed8..5da2733 100644 --- a/bt/composites/bt_parallel.h +++ b/bt/composites/bt_parallel.h @@ -4,7 +4,7 @@ #define BT_PARALLEL_H #include "bt_composite.h" -#include "core/object.h" +#include "core/object/object.h" class BTParallel : public BTComposite { GDCLASS(BTParallel, BTComposite); @@ -17,8 +17,8 @@ private: protected: static void _bind_methods(); - virtual void _enter(); - virtual int _tick(float p_delta); + virtual void _enter() override; + virtual int _tick(float p_delta) override; public: int get_num_successes_required() const { return num_successes_required; } diff --git a/bt/composites/bt_random_selector.h b/bt/composites/bt_random_selector.h index 1415072..94603cd 100644 --- a/bt/composites/bt_random_selector.h +++ b/bt/composites/bt_random_selector.h @@ -4,7 +4,7 @@ #define BT_RANDOM_SELECTOR_H #include "bt_composite.h" -#include "core/vector.h" +#include "core/templates/vector.h" class BTRandomSelector : public BTComposite { GDCLASS(BTRandomSelector, BTComposite); @@ -14,7 +14,7 @@ private: Array _indicies; protected: - virtual void _enter(); - virtual int _tick(float p_delta); + virtual void _enter() override; + virtual int _tick(float p_delta) override; }; #endif // BT_RANDOM_SELECTOR_H \ No newline at end of file diff --git a/bt/composites/bt_random_sequence.h b/bt/composites/bt_random_sequence.h index 0fd3404..06cf178 100644 --- a/bt/composites/bt_random_sequence.h +++ b/bt/composites/bt_random_sequence.h @@ -4,7 +4,7 @@ #define BT_RANDOM_SEQUENCE_H #include "bt_composite.h" -#include "core/vector.h" +#include "core/templates/vector.h" class BTRandomSequence : public BTComposite { GDCLASS(BTRandomSequence, BTComposite); @@ -14,7 +14,7 @@ private: Array _indicies; protected: - virtual void _enter(); - virtual int _tick(float p_delta); + virtual void _enter() override; + virtual int _tick(float p_delta) override; }; #endif // BT_RANDOM_SEQUENCE_H \ No newline at end of file diff --git a/bt/composites/bt_selector.h b/bt/composites/bt_selector.h index 5ea52d5..bc43994 100644 --- a/bt/composites/bt_selector.h +++ b/bt/composites/bt_selector.h @@ -12,7 +12,7 @@ private: int last_running_idx = 0; protected: - virtual void _enter(); - virtual int _tick(float p_delta); + virtual void _enter() override; + virtual int _tick(float p_delta) override; }; #endif // BT_SELECTOR_H \ No newline at end of file diff --git a/bt/composites/bt_sequence.h b/bt/composites/bt_sequence.h index a1556de..dd61497 100644 --- a/bt/composites/bt_sequence.h +++ b/bt/composites/bt_sequence.h @@ -4,7 +4,7 @@ #define BT_SEQUENCE_H #include "bt_composite.h" -#include "core/object.h" +#include "core/object/object.h" class BTSequence : public BTComposite { GDCLASS(BTSequence, BTComposite); @@ -13,8 +13,8 @@ private: int last_running_idx = 0; protected: - virtual void _enter(); - virtual int _tick(float p_delta); + virtual void _enter() override; + virtual int _tick(float p_delta) override; }; #endif // BT_SEQUENCE_H \ No newline at end of file diff --git a/bt/conditions/bt_condition.cpp b/bt/conditions/bt_condition.cpp index f3c1d5b..9746d71 100644 --- a/bt/conditions/bt_condition.cpp +++ b/bt/conditions/bt_condition.cpp @@ -4,7 +4,7 @@ String BTCondition::get_configuration_warning() const { String warning = BTTask::get_configuration_warning(); - if (!warning.empty()) { + if (!warning.is_empty()) { warning += "\n"; } if (get_child_count() != 0) { diff --git a/bt/conditions/bt_condition.h b/bt/conditions/bt_condition.h index 9cb60db..1158d72 100644 --- a/bt/conditions/bt_condition.h +++ b/bt/conditions/bt_condition.h @@ -4,13 +4,13 @@ #define BT_CONDITION_H #include "../bt_task.h" -#include "core/object.h" +#include "core/object/object.h" class BTCondition : public BTTask { GDCLASS(BTCondition, BTTask); public: - virtual String get_configuration_warning() const; + virtual String get_configuration_warning() const override; }; #endif // BT_CONDITION_H \ No newline at end of file diff --git a/bt/decorators/bt_always_fail.h b/bt/decorators/bt_always_fail.h index e67a101..9021313 100644 --- a/bt/decorators/bt_always_fail.h +++ b/bt/decorators/bt_always_fail.h @@ -4,13 +4,13 @@ #define BT_ALWAYS_FAIL_H #include "bt_decorator.h" -#include "core/object.h" +#include "core/object/object.h" class BTAlwaysFail : public BTDecorator { GDCLASS(BTAlwaysFail, BTDecorator); protected: - virtual int _tick(float p_delta); + virtual int _tick(float p_delta) override; }; #endif // BT_ALWAYS_FAIL_H \ No newline at end of file diff --git a/bt/decorators/bt_always_succeed.h b/bt/decorators/bt_always_succeed.h index 58a4179..936349c 100644 --- a/bt/decorators/bt_always_succeed.h +++ b/bt/decorators/bt_always_succeed.h @@ -4,13 +4,13 @@ #define BT_ALWAYS_SUCCEED_H #include "bt_decorator.h" -#include "core/object.h" +#include "core/object/object.h" class BTAlwaysSucceed : public BTDecorator { GDCLASS(BTAlwaysSucceed, BTDecorator); protected: - virtual int _tick(float p_delta); + virtual int _tick(float p_delta) override; }; #endif // BT_ALWAYS_SUCCEED_H \ No newline at end of file diff --git a/bt/decorators/bt_cooldown.cpp b/bt/decorators/bt_cooldown.cpp index d0dd76a..089e1f0 100644 --- a/bt/decorators/bt_cooldown.cpp +++ b/bt/decorators/bt_cooldown.cpp @@ -1,8 +1,8 @@ /* bt_cooldown.cpp */ #include "bt_cooldown.h" -#include "core/array.h" -#include "core/class_db.h" +#include "core/object/class_db.h" +#include "core/variant/array.h" #include "scene/main/scene_tree.h" String BTCooldown::_generate_name() const { @@ -10,7 +10,7 @@ String BTCooldown::_generate_name() const { } void BTCooldown::_setup() { - if (cooldown_state_var.empty()) { + if (cooldown_state_var.is_empty()) { cooldown_state_var = vformat("cooldown_%d", rand()); } get_blackboard()->set_var(cooldown_state_var, false); @@ -37,7 +37,7 @@ void BTCooldown::_chill() { _timer->set_time_left(duration); } else { _timer = SceneTree::get_singleton()->create_timer(duration, process_pause); - _timer->connect("timeout", this, "_on_timeout", Vector(), 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("_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, "start_cooled"), "set_start_cooled", "get_start_cooled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "trigger_on_failure"), "set_trigger_on_failure", "get_trigger_on_failure"); diff --git a/bt/decorators/bt_cooldown.h b/bt/decorators/bt_cooldown.h index 4169406..1474df4 100644 --- a/bt/decorators/bt_cooldown.h +++ b/bt/decorators/bt_cooldown.h @@ -4,7 +4,7 @@ #define BT_COOLDOWN_H #include "bt_decorator.h" -#include "core/object.h" +#include "core/object/object.h" #include "scene/main/scene_tree.h" class BTCooldown : public BTDecorator { @@ -25,9 +25,9 @@ private: protected: static void _bind_methods(); - virtual String _generate_name() const; - virtual void _setup(); - virtual int _tick(float p_delta); + virtual String _generate_name() const override; + virtual void _setup() override; + virtual int _tick(float p_delta) override; public: void set_duration(float p_value) { diff --git a/bt/decorators/bt_decorator.cpp b/bt/decorators/bt_decorator.cpp index afab3c5..fc8388d 100644 --- a/bt/decorators/bt_decorator.cpp +++ b/bt/decorators/bt_decorator.cpp @@ -4,7 +4,7 @@ String BTDecorator::get_configuration_warning() const { String warning = BTTask::get_configuration_warning(); - if (!warning.empty()) { + if (!warning.is_empty()) { warning += "\n"; } if (get_child_count() != 1) { diff --git a/bt/decorators/bt_decorator.h b/bt/decorators/bt_decorator.h index 75f6aa7..93af2ec 100644 --- a/bt/decorators/bt_decorator.h +++ b/bt/decorators/bt_decorator.h @@ -4,13 +4,13 @@ #define BT_DECORATOR_H #include "../bt_task.h" -#include "core/object.h" +#include "core/object/object.h" class BTDecorator : public BTTask { GDCLASS(BTDecorator, BTTask) public: - virtual String get_configuration_warning() const; + virtual String get_configuration_warning() const override; }; #endif // BT_DECORATOR_H \ No newline at end of file diff --git a/bt/decorators/bt_delay.cpp b/bt/decorators/bt_delay.cpp index 4118a26..3e8a285 100644 --- a/bt/decorators/bt_delay.cpp +++ b/bt/decorators/bt_delay.cpp @@ -1,11 +1,11 @@ /* bt_delay.cpp */ #include "bt_delay.h" -#include "core/array.h" -#include "core/class_db.h" -#include "core/error_macros.h" -#include "core/object.h" -#include "core/variant.h" +#include "core/error/error_macros.h" +#include "core/object/class_db.h" +#include "core/object/object.h" +#include "core/variant/array.h" +#include "core/variant/variant.h" String BTDelay::_generate_name() const { return vformat("Delay %ss", seconds); @@ -27,5 +27,5 @@ int BTDelay::_tick(float p_delta) { void BTDelay::_bind_methods() { ClassDB::bind_method(D_METHOD("set_seconds", "p_value"), &BTDelay::set_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"); } diff --git a/bt/decorators/bt_delay.h b/bt/decorators/bt_delay.h index d0c5b9f..34e4267 100644 --- a/bt/decorators/bt_delay.h +++ b/bt/decorators/bt_delay.h @@ -4,7 +4,7 @@ #define BT_DELAY_H #include "bt_decorator.h" -#include "core/object.h" +#include "core/object/object.h" class BTDelay : public BTDecorator { GDCLASS(BTDelay, BTDecorator); @@ -16,9 +16,9 @@ private: protected: static void _bind_methods(); - virtual String _generate_name() const; - virtual void _enter(); - virtual int _tick(float p_delta); + virtual String _generate_name() const override; + virtual void _enter() override; + virtual int _tick(float p_delta) override; public: void set_seconds(float p_value) { diff --git a/bt/decorators/bt_for_each.cpp b/bt/decorators/bt_for_each.cpp index 5ff038c..46d5fb8 100644 --- a/bt/decorators/bt_for_each.cpp +++ b/bt/decorators/bt_for_each.cpp @@ -1,9 +1,9 @@ /* bt_for_each.cpp */ #include "bt_for_each.h" -#include "core/error_list.h" -#include "core/error_macros.h" -#include "core/variant.h" +#include "core/error/error_list.h" +#include "core/error/error_macros.h" +#include "core/variant/variant.h" #include "modules/limboai/blackboard.h" #include "modules/limboai/limbo_utility.h" @@ -19,8 +19,8 @@ void BTForEach::_enter() { 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(save_var.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(save_var.is_empty(), FAILURE, "ForEach save 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()); if (arr.size() == 0) { diff --git a/bt/decorators/bt_for_each.h b/bt/decorators/bt_for_each.h index 94aea10..9f65ca0 100644 --- a/bt/decorators/bt_for_each.h +++ b/bt/decorators/bt_for_each.h @@ -4,7 +4,7 @@ #define BT_FOR_EACH_H #include "bt_decorator.h" -#include "core/object.h" +#include "core/object/object.h" class BTForEach : public BTDecorator { GDCLASS(BTForEach, BTDecorator); @@ -18,9 +18,9 @@ private: protected: static void _bind_methods(); - virtual String _generate_name() const; - virtual void _enter(); - virtual int _tick(float p_delta); + virtual String _generate_name() const override; + virtual void _enter() override; + virtual int _tick(float p_delta) override; public: void set_array_var(String p_value) { diff --git a/bt/decorators/bt_invert.h b/bt/decorators/bt_invert.h index 6f8875a..5b0519b 100644 --- a/bt/decorators/bt_invert.h +++ b/bt/decorators/bt_invert.h @@ -4,13 +4,13 @@ #define BT_INVERT_H #include "bt_decorator.h" -#include "core/object.h" +#include "core/object/object.h" class BTInvert : public BTDecorator { GDCLASS(BTInvert, BTDecorator); protected: - virtual int _tick(float p_delta); + virtual int _tick(float p_delta) override; }; #endif // BT_INVERT_H \ No newline at end of file diff --git a/bt/decorators/bt_new_scope.cpp b/bt/decorators/bt_new_scope.cpp index 8670185..4b9864c 100644 --- a/bt/decorators/bt_new_scope.cpp +++ b/bt/decorators/bt_new_scope.cpp @@ -1,9 +1,9 @@ /* bt_new_scope.cpp */ #include "bt_new_scope.h" -#include "core/error_macros.h" +#include "core/error/error_macros.h" #include "core/os/memory.h" -#include "core/ustring.h" +#include "core/string/ustring.h" #include "modules/limboai/blackboard.h" void BTNewScope::initialize(Object *p_agent, const Ref &p_blackboard) { diff --git a/bt/decorators/bt_new_scope.h b/bt/decorators/bt_new_scope.h index 18d4fcb..10a4542 100644 --- a/bt/decorators/bt_new_scope.h +++ b/bt/decorators/bt_new_scope.h @@ -4,7 +4,7 @@ #define BT_NEW_SCOPE_H #include "bt_decorator.h" -#include "core/object.h" +#include "core/object/object.h" #include "bt_decorator.h" class BTNewScope : public BTDecorator { @@ -19,10 +19,10 @@ protected: void _set_blackboard_data(const Dictionary &p_value) { blackboard_data = p_value; } Dictionary _get_blackboard_data() const { return blackboard_data; } - virtual int _tick(float p_delta); + virtual int _tick(float p_delta) override; public: - virtual void initialize(Object *p_agent, const Ref &p_blackboard); + virtual void initialize(Object *p_agent, const Ref &p_blackboard) override; }; #endif // BT_NEW_SCOPE_H \ No newline at end of file diff --git a/bt/decorators/bt_probability.cpp b/bt/decorators/bt_probability.cpp index c656c17..ec149fc 100644 --- a/bt/decorators/bt_probability.cpp +++ b/bt/decorators/bt_probability.cpp @@ -1,7 +1,7 @@ /* bt_probability.cpp */ #include "bt_probability.h" -#include "core/object.h" +#include "core/object/object.h" String BTProbability::_generate_name() const { return vformat("Probability %.1f%%", run_chance); @@ -18,5 +18,5 @@ int BTProbability::_tick(float p_delta) { void BTProbability::_bind_methods() { 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); - 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"); } diff --git a/bt/decorators/bt_probability.h b/bt/decorators/bt_probability.h index 3e73202..7aa7613 100644 --- a/bt/decorators/bt_probability.h +++ b/bt/decorators/bt_probability.h @@ -4,7 +4,7 @@ #define BT_PROBABILITY_H #include "bt_decorator.h" -#include "core/object.h" +#include "core/object/object.h" class BTProbability : public BTDecorator { GDCLASS(BTProbability, BTDecorator); @@ -15,8 +15,8 @@ private: protected: static void _bind_methods(); - virtual String _generate_name() const; - virtual int _tick(float p_delta); + virtual String _generate_name() const override; + virtual int _tick(float p_delta) override; public: void set_run_chance(float p_value) { diff --git a/bt/decorators/bt_repeat.cpp b/bt/decorators/bt_repeat.cpp index 607a4e1..406fb2b 100644 --- a/bt/decorators/bt_repeat.cpp +++ b/bt/decorators/bt_repeat.cpp @@ -1,8 +1,8 @@ /* bt_repeat.cpp */ #include "bt_repeat.h" -#include "core/object.h" -#include "core/variant.h" +#include "core/object/object.h" +#include "core/variant/variant.h" String BTRepeat::_generate_name() const { return vformat("Repeat x%s", times); diff --git a/bt/decorators/bt_repeat.h b/bt/decorators/bt_repeat.h index e56dfaf..2e629fa 100644 --- a/bt/decorators/bt_repeat.h +++ b/bt/decorators/bt_repeat.h @@ -4,7 +4,7 @@ #define BT_REPEAT_H #include "bt_decorator.h" -#include "core/object.h" +#include "core/object/object.h" class BTRepeat : public BTDecorator { GDCLASS(BTRepeat, BTDecorator); @@ -17,9 +17,9 @@ private: protected: static void _bind_methods(); - virtual String _generate_name() const; - virtual void _enter(); - virtual int _tick(float p_delta); + virtual String _generate_name() const override; + virtual void _enter() override; + virtual int _tick(float p_delta) override; public: void set_times(int p_value) { diff --git a/bt/decorators/bt_repeat_until_failure.h b/bt/decorators/bt_repeat_until_failure.h index 12de583..5e06795 100644 --- a/bt/decorators/bt_repeat_until_failure.h +++ b/bt/decorators/bt_repeat_until_failure.h @@ -4,13 +4,13 @@ #define BT_REPEAT_UNTIL_FAILURE_H #include "bt_decorator.h" -#include "core/object.h" +#include "core/object/object.h" class BTRepeatUntilFailure : public BTDecorator { GDCLASS(BTRepeatUntilFailure, BTDecorator); protected: - virtual int _tick(float p_delta); + virtual int _tick(float p_delta) override; }; #endif // BT_REPEAT_UNTIL_FAILURE_H \ No newline at end of file diff --git a/bt/decorators/bt_repeat_until_success.h b/bt/decorators/bt_repeat_until_success.h index db83ea6..7729379 100644 --- a/bt/decorators/bt_repeat_until_success.h +++ b/bt/decorators/bt_repeat_until_success.h @@ -4,13 +4,13 @@ #define BT_REPEAT_UNTIL_SUCCESS_H #include "bt_decorator.h" -#include "core/object.h" +#include "core/object/object.h" class BTRepeatUntilSuccess : public BTDecorator { GDCLASS(BTRepeatUntilSuccess, BTDecorator); protected: - virtual int _tick(float p_delta); + virtual int _tick(float p_delta) override; }; #endif // BT_REPEAT_UNTIL_SUCCESS_H \ No newline at end of file diff --git a/bt/decorators/bt_run_limit.h b/bt/decorators/bt_run_limit.h index 313d358..75ab8b5 100644 --- a/bt/decorators/bt_run_limit.h +++ b/bt/decorators/bt_run_limit.h @@ -4,7 +4,7 @@ #define BT_RUN_LIMIT_H #include "bt_decorator.h" -#include "core/object.h" +#include "core/object/object.h" class BTRunLimit : public BTDecorator { GDCLASS(BTRunLimit, BTDecorator); @@ -16,8 +16,8 @@ private: protected: static void _bind_methods(); - virtual String _generate_name() const; - virtual int _tick(float p_delta); + virtual String _generate_name() const override; + virtual int _tick(float p_delta) override; public: void set_run_limit(int p_value) { diff --git a/bt/decorators/bt_subtree.cpp b/bt/decorators/bt_subtree.cpp index 0801b25..341708e 100644 --- a/bt/decorators/bt_subtree.cpp +++ b/bt/decorators/bt_subtree.cpp @@ -1,11 +1,11 @@ /* bt_subtree.cpp */ #include "bt_subtree.h" -#include "core/engine.h" -#include "core/error_macros.h" -#include "core/object.h" +#include "core/config/engine.h" +#include "core/error/error_macros.h" +#include "core/object/object.h" #include "core/typedefs.h" -#include "core/variant.h" +#include "core/variant/variant.h" #include "modules/limboai/blackboard.h" #include "modules/limboai/bt/actions/bt_action.h" #include "modules/limboai/bt/actions/bt_fail.h" @@ -17,7 +17,7 @@ String BTSubtree::_generate_name() const { String s; if (subtree.is_null()) { s = "(unassigned)"; - } else if (subtree->get_path().empty()) { + } else if (subtree->get_path().is_empty()) { s = "(unsaved)"; } else { s = vformat("\"%s\"", subtree->get_path()); @@ -46,7 +46,7 @@ int BTSubtree::_tick(float p_delta) { String BTSubtree::get_configuration_warning() const { String warning = BTTask::get_configuration_warning(); // BTDecorator skipped intentionally - if (!warning.empty()) { + if (!warning.is_empty()) { warning += "\n"; } if (subtree.is_null()) { diff --git a/bt/decorators/bt_subtree.h b/bt/decorators/bt_subtree.h index 90fade7..cde74ae 100644 --- a/bt/decorators/bt_subtree.h +++ b/bt/decorators/bt_subtree.h @@ -4,7 +4,7 @@ #define BT_SUBTREE_H #include "bt_new_scope.h" -#include "core/object.h" +#include "core/object/object.h" #include "modules/limboai/bt/behavior_tree.h" class BTSubtree : public BTNewScope { @@ -16,8 +16,8 @@ private: protected: static void _bind_methods(); - virtual String _generate_name() const; - virtual int _tick(float p_delta); + virtual String _generate_name() const override; + virtual int _tick(float p_delta) override; public: void set_subtree(const Ref &p_value) { @@ -26,8 +26,8 @@ public: } Ref get_subtree() const { return subtree; } - virtual void initialize(Object *p_agent, const Ref &p_blackboard); - virtual String get_configuration_warning() const; + virtual void initialize(Object *p_agent, const Ref &p_blackboard) override; + virtual String get_configuration_warning() const override; }; #endif // BT_SUBTREE_H \ No newline at end of file diff --git a/bt/decorators/bt_time_limit.cpp b/bt/decorators/bt_time_limit.cpp index 2ab6d2f..791f4ab 100644 --- a/bt/decorators/bt_time_limit.cpp +++ b/bt/decorators/bt_time_limit.cpp @@ -24,5 +24,5 @@ int BTTimeLimit::_tick(float p_delta) { void BTTimeLimit::_bind_methods() { 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); - 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"); } diff --git a/bt/decorators/bt_time_limit.h b/bt/decorators/bt_time_limit.h index ef2dd25..cc99f95 100644 --- a/bt/decorators/bt_time_limit.h +++ b/bt/decorators/bt_time_limit.h @@ -4,7 +4,7 @@ #define BT_TIME_LIMIT_H #include "bt_decorator.h" -#include "core/object.h" +#include "core/object/object.h" class BTTimeLimit : public BTDecorator { GDCLASS(BTTimeLimit, BTDecorator); @@ -16,9 +16,9 @@ private: protected: static void _bind_methods(); - virtual String _generate_name() const; - virtual void _enter(); - virtual int _tick(float p_delta); + virtual String _generate_name() const override; + virtual void _enter() override; + virtual int _tick(float p_delta) override; public: void set_time_limit(float p_value) { diff --git a/config.py b/config.py index 85a1238..bd07da5 100644 --- a/config.py +++ b/config.py @@ -13,6 +13,10 @@ def get_doc_path(): return "doc_classes" +# def get_icons_path(): +# return "icons" + + def get_doc_classes(): return [ "BBAabb", diff --git a/editor/limbo_ai_editor_plugin.cpp b/editor/limbo_ai_editor_plugin.cpp index 8c24ef6..828c776 100644 --- a/editor/limbo_ai_editor_plugin.cpp +++ b/editor/limbo_ai_editor_plugin.cpp @@ -4,35 +4,40 @@ #include "limbo_ai_editor_plugin.h" -#include "core/array.h" -#include "core/class_db.h" -#include "core/dictionary.h" -#include "core/error_list.h" -#include "core/error_macros.h" +#include "core/config/project_settings.h" +#include "core/error/error_list.h" +#include "core/error/error_macros.h" #include "core/io/config_file.h" +#include "core/io/dir_access.h" #include "core/io/image_loader.h" +#include "core/io/resource.h" #include "core/io/resource_loader.h" #include "core/io/resource_saver.h" -#include "core/list.h" #include "core/math/math_defs.h" #include "core/math/vector2.h" -#include "core/object.h" -#include "core/os/dir_access.h" +#include "core/object/callable_method_pointer.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/print_string.h" -#include "core/project_settings.h" -#include "core/resource.h" -#include "core/script_language.h" -#include "core/string_name.h" +#include "core/string/print_string.h" +#include "core/string/string_name.h" +#include "core/string/ustring.h" +#include "core/templates/list.h" +#include "core/templates/vector.h" #include "core/typedefs.h" -#include "core/ustring.h" -#include "core/variant.h" -#include "core/vector.h" +#include "core/variant/array.h" +#include "core/variant/dictionary.h" +#include "core/variant/variant.h" +#include "editor/editor_file_system.h" #include "editor/editor_inspector.h" #include "editor/editor_node.h" +#include "editor/editor_paths.h" #include "editor/editor_plugin.h" #include "editor/editor_scale.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/behavior_tree.h" #include "modules/limboai/bt/bt_task.h" @@ -51,7 +56,7 @@ #include "scene/gui/separator.h" #include "scene/gui/split_container.h" #include "scene/gui/tree.h" -#include +#include "servers/display_server.h" ////////////////////////////// TaskTree ////////////////////////////////////// @@ -72,7 +77,7 @@ void TaskTree::_update_item(TreeItem *p_item) { Ref task = p_item->get_metadata(0); ERR_FAIL_COND_MSG(!task.is_valid(), "Invalid task reference in metadata."); 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())); } else { 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); } String warning = task->get_configuration_warning(); - if (!warning.empty()) { - p_item->add_button(0, get_icon("NodeWarning", "EditorIcons"), 0, false, warning); + if (!warning.is_empty()) { + p_item->add_button(0, get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons")), 0, false, warning); } // TODO: Update probabilities. @@ -114,11 +119,11 @@ TreeItem *TaskTree::_find_item(const Ref &p_task) const { TreeItem *item = tree->get_root(); List stack; while (item && item->get_metadata(0) != p_task) { - if (item->get_children()) { - stack.push_back(item->get_children()); + if (item->get_child_count() > 0) { + stack.push_back(item->get_first_child()); } item = item->get_next(); - if (item == nullptr && !stack.empty()) { + if (item == nullptr && !stack.is_empty()) { item = stack.front()->get(); stack.pop_front(); } @@ -126,19 +131,21 @@ TreeItem *TaskTree::_find_item(const Ref &p_task) const { return item; } -void TaskTree::_on_item_rmb_selected(const Vector2 &p_pos) { - emit_signal("rmb_pressed", tree->get_global_transform().xform(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)); + } } void TaskTree::_on_item_selected() { if (last_selected.is_valid()) { update_task(last_selected); - if (last_selected->is_connected("changed", this, "_on_task_changed")) { - last_selected->disconnect("changed", this, "_on_task_changed"); + if (last_selected->is_connected("changed", callable_mp(this, &TaskTree::_on_task_changed))) { + last_selected->disconnect("changed", callable_mp(this, &TaskTree::_on_task_changed)); } } 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); } @@ -153,8 +160,8 @@ void TaskTree::_on_task_changed() { void TaskTree::load_bt(const Ref &p_behavior_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")) { - last_selected->disconnect("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", callable_mp(this, &TaskTree::_on_task_changed)); } 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)) { Dictionary drag_data; drag_data["type"] = "task"; @@ -197,7 +204,7 @@ Variant TaskTree::get_drag_data_fw(const Point2 &p_point, Control *p_from) { 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) { return false; } @@ -224,7 +231,7 @@ bool TaskTree::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Co 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; TreeItem *item = tree->get_item_at_position(p_point); 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() { - 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_double_clicked"), &TaskTree::_on_item_double_clicked); 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("deselect"), &TaskTree::deselect); - 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("drop_data_fw"), &TaskTree::drop_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("_drop_data_fw"), &TaskTree::_drop_data_fw); ADD_SIGNAL(MethodInfo("rmb_pressed")); ADD_SIGNAL(MethodInfo("task_selected")); @@ -266,19 +273,20 @@ TaskTree::TaskTree() { tree->set_columns(2); tree->set_column_expand(0, true); tree->set_column_expand(1, false); - tree->set_column_min_width(1, 64); - tree->set_anchor(MARGIN_RIGHT, ANCHOR_END); - tree->set_anchor(MARGIN_BOTTOM, ANCHOR_END); + tree->set_column_custom_minimum_width(1, 64); + tree->set_anchor(SIDE_RIGHT, ANCHOR_END); + tree->set_anchor(SIDE_BOTTOM, ANCHOR_END); tree->set_allow_rmb_select(true); - tree->connect("item_rmb_selected", this, "_on_item_rmb_selected"); - tree->connect("item_selected", this, "_on_item_selected"); - tree->connect("item_activated", this, "_on_item_double_clicked"); + tree->connect("item_mouse_selected", callable_mp(this, &TaskTree::_on_item_mouse_selected)); + tree->connect("item_selected", callable_mp(this, &TaskTree::_on_item_selected)); + tree->connect("item_activated", callable_mp(this, &TaskTree::_on_item_double_clicked)); + tree->set_drag_forwarding(this); } TaskTree::~TaskTree() { - if (last_selected.is_valid() and last_selected->is_connected("changed", this, "_on_task_changed")) { - last_selected->disconnect("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", 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() { 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) { 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++) { Object::cast_to