diff --git a/SCsub b/SCsub index cbc789a..136a438 100644 --- a/SCsub +++ b/SCsub @@ -10,10 +10,12 @@ module_env.add_source_files(env.modules_sources, "blackboard/*.cpp") module_env.add_source_files(env.modules_sources, "blackboard/bb_param/*.cpp") module_env.add_source_files(env.modules_sources, "bt/*.cpp") module_env.add_source_files(env.modules_sources, "bt/tasks/*.cpp") +module_env.add_source_files(env.modules_sources, "bt/tasks/blackboard/*.cpp") module_env.add_source_files(env.modules_sources, "bt/tasks/composites/*.cpp") -module_env.add_source_files(env.modules_sources, "bt/tasks/actions/*.cpp") module_env.add_source_files(env.modules_sources, "bt/tasks/decorators/*.cpp") -module_env.add_source_files(env.modules_sources, "bt/tasks/conditions/*.cpp") +module_env.add_source_files(env.modules_sources, "bt/tasks/misc/*.cpp") +module_env.add_source_files(env.modules_sources, "bt/tasks/scene/*.cpp") +module_env.add_source_files(env.modules_sources, "bt/tasks/utility/*.cpp") if env.editor_build: module_env.add_source_files(env.modules_sources, "editor/*.cpp") module_env.add_source_files(env.modules_sources, "editor/debugger/*.cpp") diff --git a/bt/tasks/conditions/bt_check_trigger.cpp b/bt/tasks/blackboard/bt_check_trigger.cpp similarity index 100% rename from bt/tasks/conditions/bt_check_trigger.cpp rename to bt/tasks/blackboard/bt_check_trigger.cpp diff --git a/bt/tasks/conditions/bt_check_trigger.h b/bt/tasks/blackboard/bt_check_trigger.h similarity index 94% rename from bt/tasks/conditions/bt_check_trigger.h rename to bt/tasks/blackboard/bt_check_trigger.h index f7d899d..e3ca3e0 100644 --- a/bt/tasks/conditions/bt_check_trigger.h +++ b/bt/tasks/blackboard/bt_check_trigger.h @@ -9,8 +9,6 @@ * ============================================================================= */ -/* bt_check_trigger.h */ - #ifndef BT_CHECK_TRIGGER_H #define BT_CHECK_TRIGGER_H @@ -20,6 +18,7 @@ class BTCheckTrigger : public BTCondition { GDCLASS(BTCheckTrigger, BTCondition); + TASK_CATEGORY(Blackboard); private: String variable; diff --git a/bt/tasks/conditions/bt_check_var.cpp b/bt/tasks/blackboard/bt_check_var.cpp similarity index 100% rename from bt/tasks/conditions/bt_check_var.cpp rename to bt/tasks/blackboard/bt_check_var.cpp diff --git a/bt/tasks/conditions/bt_check_var.h b/bt/tasks/blackboard/bt_check_var.h similarity index 96% rename from bt/tasks/conditions/bt_check_var.h rename to bt/tasks/blackboard/bt_check_var.h index 2ff9815..ae87574 100644 --- a/bt/tasks/conditions/bt_check_var.h +++ b/bt/tasks/blackboard/bt_check_var.h @@ -19,6 +19,7 @@ class BTCheckVar : public BTCondition { GDCLASS(BTCheckVar, BTCondition); + TASK_CATEGORY(Blackboard); private: String variable; diff --git a/bt/tasks/actions/bt_set_var.cpp b/bt/tasks/blackboard/bt_set_var.cpp similarity index 100% rename from bt/tasks/actions/bt_set_var.cpp rename to bt/tasks/blackboard/bt_set_var.cpp diff --git a/bt/tasks/actions/bt_set_var.h b/bt/tasks/blackboard/bt_set_var.h similarity index 95% rename from bt/tasks/actions/bt_set_var.h rename to bt/tasks/blackboard/bt_set_var.h index 7fb2b51..00d35f5 100644 --- a/bt/tasks/actions/bt_set_var.h +++ b/bt/tasks/blackboard/bt_set_var.h @@ -8,7 +8,6 @@ * https://opensource.org/licenses/MIT. * ============================================================================= */ -/* bt_set_var.h */ #ifndef BT_SET_VAR_H #define BT_SET_VAR_H @@ -21,6 +20,7 @@ class BTSetVar : public BTAction { GDCLASS(BTSetVar, BTAction); + TASK_CATEGORY(Blackboard); private: String variable; diff --git a/bt/tasks/bt_comment.h b/bt/tasks/bt_comment.h index 442db08..3bb59f2 100644 --- a/bt/tasks/bt_comment.h +++ b/bt/tasks/bt_comment.h @@ -8,7 +8,6 @@ * https://opensource.org/licenses/MIT. * ============================================================================= */ -/* bt_comment.h */ #ifndef BT_COMMENT_H #define BT_COMMENT_H @@ -17,8 +16,8 @@ class BTComment : public BTTask { GDCLASS(BTComment, BTTask); + TASK_CATEGORY(Utility); -private: public: virtual Ref clone() const override; virtual PackedStringArray get_configuration_warnings() const override; diff --git a/bt/tasks/bt_task.h b/bt/tasks/bt_task.h index 80e28c1..6728b64 100644 --- a/bt/tasks/bt_task.h +++ b/bt/tasks/bt_task.h @@ -13,6 +13,7 @@ #define BTTASK_H #include "modules/limboai/blackboard/blackboard.h" +#include "modules/limboai/util/limbo_task_db.h" #include "core/io/resource.h" #include "core/object/object.h" diff --git a/bt/tasks/composites/bt_dynamic_selector.h b/bt/tasks/composites/bt_dynamic_selector.h index b5d0631..e1b7246 100644 --- a/bt/tasks/composites/bt_dynamic_selector.h +++ b/bt/tasks/composites/bt_dynamic_selector.h @@ -16,6 +16,7 @@ class BTDynamicSelector : public BTComposite { GDCLASS(BTDynamicSelector, BTComposite); + TASK_CATEGORY(Composites); private: int last_running_idx = 0; diff --git a/bt/tasks/composites/bt_dynamic_sequence.h b/bt/tasks/composites/bt_dynamic_sequence.h index 3f5813a..d331eca 100644 --- a/bt/tasks/composites/bt_dynamic_sequence.h +++ b/bt/tasks/composites/bt_dynamic_sequence.h @@ -16,6 +16,7 @@ class BTDynamicSequence : public BTComposite { GDCLASS(BTDynamicSequence, BTComposite); + TASK_CATEGORY(Composites); private: int last_running_idx = 0; diff --git a/bt/tasks/composites/bt_parallel.h b/bt/tasks/composites/bt_parallel.h index 93cf0b5..40f18e7 100644 --- a/bt/tasks/composites/bt_parallel.h +++ b/bt/tasks/composites/bt_parallel.h @@ -16,6 +16,7 @@ class BTParallel : public BTComposite { GDCLASS(BTParallel, BTComposite); + TASK_CATEGORY(Composites); private: int num_successes_required = 1; diff --git a/bt/tasks/composites/bt_random_selector.h b/bt/tasks/composites/bt_random_selector.h index 1f10527..710b5e3 100644 --- a/bt/tasks/composites/bt_random_selector.h +++ b/bt/tasks/composites/bt_random_selector.h @@ -18,6 +18,7 @@ class BTRandomSelector : public BTComposite { GDCLASS(BTRandomSelector, BTComposite); + TASK_CATEGORY(Composites); private: int last_running_idx = 0; diff --git a/bt/tasks/composites/bt_random_sequence.h b/bt/tasks/composites/bt_random_sequence.h index c2ed551..866cb78 100644 --- a/bt/tasks/composites/bt_random_sequence.h +++ b/bt/tasks/composites/bt_random_sequence.h @@ -18,6 +18,7 @@ class BTRandomSequence : public BTComposite { GDCLASS(BTRandomSequence, BTComposite); + TASK_CATEGORY(Composites); private: int last_running_idx = 0; diff --git a/bt/tasks/composites/bt_selector.h b/bt/tasks/composites/bt_selector.h index c60b045..eb3be08 100644 --- a/bt/tasks/composites/bt_selector.h +++ b/bt/tasks/composites/bt_selector.h @@ -16,6 +16,7 @@ class BTSelector : public BTComposite { GDCLASS(BTSelector, BTComposite); + TASK_CATEGORY(Composites); private: int last_running_idx = 0; diff --git a/bt/tasks/composites/bt_sequence.h b/bt/tasks/composites/bt_sequence.h index b82174f..45b61d6 100644 --- a/bt/tasks/composites/bt_sequence.h +++ b/bt/tasks/composites/bt_sequence.h @@ -16,6 +16,7 @@ class BTSequence : public BTComposite { GDCLASS(BTSequence, BTComposite); + TASK_CATEGORY(Composites); private: int last_running_idx = 0; diff --git a/bt/tasks/decorators/bt_always_fail.h b/bt/tasks/decorators/bt_always_fail.h index d5e322f..eed4cf5 100644 --- a/bt/tasks/decorators/bt_always_fail.h +++ b/bt/tasks/decorators/bt_always_fail.h @@ -16,6 +16,7 @@ class BTAlwaysFail : public BTDecorator { GDCLASS(BTAlwaysFail, BTDecorator); + TASK_CATEGORY(Decorators); protected: virtual int _tick(double p_delta) override; diff --git a/bt/tasks/decorators/bt_always_succeed.h b/bt/tasks/decorators/bt_always_succeed.h index 411c595..d8700f2 100644 --- a/bt/tasks/decorators/bt_always_succeed.h +++ b/bt/tasks/decorators/bt_always_succeed.h @@ -16,6 +16,7 @@ class BTAlwaysSucceed : public BTDecorator { GDCLASS(BTAlwaysSucceed, BTDecorator); + TASK_CATEGORY(Decorators); protected: virtual int _tick(double p_delta) override; diff --git a/bt/tasks/decorators/bt_cooldown.h b/bt/tasks/decorators/bt_cooldown.h index a2b0759..8ab5979 100644 --- a/bt/tasks/decorators/bt_cooldown.h +++ b/bt/tasks/decorators/bt_cooldown.h @@ -18,6 +18,7 @@ class BTCooldown : public BTDecorator { GDCLASS(BTCooldown, BTDecorator); + TASK_CATEGORY(Decorators); private: double duration = 10.0; diff --git a/bt/tasks/decorators/bt_delay.h b/bt/tasks/decorators/bt_delay.h index 8093658..ee3eda2 100644 --- a/bt/tasks/decorators/bt_delay.h +++ b/bt/tasks/decorators/bt_delay.h @@ -16,6 +16,7 @@ class BTDelay : public BTDecorator { GDCLASS(BTDelay, BTDecorator); + TASK_CATEGORY(Decorators); private: double seconds = 1.0; diff --git a/bt/tasks/decorators/bt_for_each.h b/bt/tasks/decorators/bt_for_each.h index 41479b6..527093f 100644 --- a/bt/tasks/decorators/bt_for_each.h +++ b/bt/tasks/decorators/bt_for_each.h @@ -16,6 +16,7 @@ class BTForEach : public BTDecorator { GDCLASS(BTForEach, BTDecorator); + TASK_CATEGORY(Decorators); private: String array_var; diff --git a/bt/tasks/decorators/bt_invert.h b/bt/tasks/decorators/bt_invert.h index b224cd0..cc3f707 100644 --- a/bt/tasks/decorators/bt_invert.h +++ b/bt/tasks/decorators/bt_invert.h @@ -16,6 +16,7 @@ class BTInvert : public BTDecorator { GDCLASS(BTInvert, BTDecorator); + TASK_CATEGORY(Decorators); protected: virtual int _tick(double p_delta) override; diff --git a/bt/tasks/decorators/bt_new_scope.h b/bt/tasks/decorators/bt_new_scope.h index 99ac94c..060b787 100644 --- a/bt/tasks/decorators/bt_new_scope.h +++ b/bt/tasks/decorators/bt_new_scope.h @@ -16,6 +16,7 @@ class BTNewScope : public BTDecorator { GDCLASS(BTNewScope, BTDecorator); + TASK_CATEGORY(Decorators); private: Dictionary blackboard_data; diff --git a/bt/tasks/decorators/bt_probability.h b/bt/tasks/decorators/bt_probability.h index 10e0309..0c5689e 100644 --- a/bt/tasks/decorators/bt_probability.h +++ b/bt/tasks/decorators/bt_probability.h @@ -16,6 +16,7 @@ class BTProbability : public BTDecorator { GDCLASS(BTProbability, BTDecorator); + TASK_CATEGORY(Decorators); private: float run_chance = 0.5; diff --git a/bt/tasks/decorators/bt_repeat.h b/bt/tasks/decorators/bt_repeat.h index 448701d..b56c14c 100644 --- a/bt/tasks/decorators/bt_repeat.h +++ b/bt/tasks/decorators/bt_repeat.h @@ -16,6 +16,7 @@ class BTRepeat : public BTDecorator { GDCLASS(BTRepeat, BTDecorator); + TASK_CATEGORY(Decorators); private: bool forever = false; diff --git a/bt/tasks/decorators/bt_repeat_until_failure.h b/bt/tasks/decorators/bt_repeat_until_failure.h index 5d7d4f4..0518927 100644 --- a/bt/tasks/decorators/bt_repeat_until_failure.h +++ b/bt/tasks/decorators/bt_repeat_until_failure.h @@ -16,6 +16,7 @@ class BTRepeatUntilFailure : public BTDecorator { GDCLASS(BTRepeatUntilFailure, BTDecorator); + TASK_CATEGORY(Decorators); protected: virtual int _tick(double p_delta) override; diff --git a/bt/tasks/decorators/bt_repeat_until_success.h b/bt/tasks/decorators/bt_repeat_until_success.h index db65e85..d26af61 100644 --- a/bt/tasks/decorators/bt_repeat_until_success.h +++ b/bt/tasks/decorators/bt_repeat_until_success.h @@ -16,6 +16,7 @@ class BTRepeatUntilSuccess : public BTDecorator { GDCLASS(BTRepeatUntilSuccess, BTDecorator); + TASK_CATEGORY(Decorators); protected: virtual int _tick(double p_delta) override; diff --git a/bt/tasks/decorators/bt_run_limit.h b/bt/tasks/decorators/bt_run_limit.h index ec694c1..26d7fa7 100644 --- a/bt/tasks/decorators/bt_run_limit.h +++ b/bt/tasks/decorators/bt_run_limit.h @@ -16,6 +16,7 @@ class BTRunLimit : public BTDecorator { GDCLASS(BTRunLimit, BTDecorator); + TASK_CATEGORY(Decorators); private: int run_limit = 1; diff --git a/bt/tasks/decorators/bt_subtree.h b/bt/tasks/decorators/bt_subtree.h index edddc7e..3c5a710 100644 --- a/bt/tasks/decorators/bt_subtree.h +++ b/bt/tasks/decorators/bt_subtree.h @@ -18,6 +18,7 @@ class BTSubtree : public BTNewScope { GDCLASS(BTSubtree, BTNewScope); + TASK_CATEGORY(Decorators); private: Ref subtree; diff --git a/bt/tasks/decorators/bt_time_limit.h b/bt/tasks/decorators/bt_time_limit.h index d0207ed..aa960bf 100644 --- a/bt/tasks/decorators/bt_time_limit.h +++ b/bt/tasks/decorators/bt_time_limit.h @@ -16,6 +16,7 @@ class BTTimeLimit : public BTDecorator { GDCLASS(BTTimeLimit, BTDecorator); + TASK_CATEGORY(Decorators); private: double time_limit = 5.0; diff --git a/bt/tasks/actions/bt_await_animation.cpp b/bt/tasks/scene/bt_await_animation.cpp similarity index 100% rename from bt/tasks/actions/bt_await_animation.cpp rename to bt/tasks/scene/bt_await_animation.cpp diff --git a/bt/tasks/actions/bt_await_animation.h b/bt/tasks/scene/bt_await_animation.h similarity index 96% rename from bt/tasks/actions/bt_await_animation.h rename to bt/tasks/scene/bt_await_animation.h index 794be74..0c56efd 100644 --- a/bt/tasks/actions/bt_await_animation.h +++ b/bt/tasks/scene/bt_await_animation.h @@ -20,6 +20,7 @@ class BTAwaitAnimation : public BTAction { GDCLASS(BTAwaitAnimation, BTAction); + TASK_CATEGORY(Scene); private: Ref animation_player_param; diff --git a/bt/tasks/actions/bt_call_method.cpp b/bt/tasks/scene/bt_call_method.cpp similarity index 100% rename from bt/tasks/actions/bt_call_method.cpp rename to bt/tasks/scene/bt_call_method.cpp diff --git a/bt/tasks/actions/bt_call_method.h b/bt/tasks/scene/bt_call_method.h similarity index 96% rename from bt/tasks/actions/bt_call_method.h rename to bt/tasks/scene/bt_call_method.h index 2761583..8445c3c 100644 --- a/bt/tasks/actions/bt_call_method.h +++ b/bt/tasks/scene/bt_call_method.h @@ -18,6 +18,7 @@ class BTCallMethod : public BTAction { GDCLASS(BTCallMethod, BTAction); + TASK_CATEGORY(Scene); private: StringName method_name; diff --git a/bt/tasks/conditions/bt_check_agent_property.cpp b/bt/tasks/scene/bt_check_agent_property.cpp similarity index 100% rename from bt/tasks/conditions/bt_check_agent_property.cpp rename to bt/tasks/scene/bt_check_agent_property.cpp diff --git a/bt/tasks/conditions/bt_check_agent_property.h b/bt/tasks/scene/bt_check_agent_property.h similarity index 96% rename from bt/tasks/conditions/bt_check_agent_property.h rename to bt/tasks/scene/bt_check_agent_property.h index 113b01f..2c50c00 100644 --- a/bt/tasks/conditions/bt_check_agent_property.h +++ b/bt/tasks/scene/bt_check_agent_property.h @@ -21,6 +21,7 @@ class BTCheckAgentProperty : public BTCondition { GDCLASS(BTCheckAgentProperty, BTCondition); + TASK_CATEGORY(Scene); private: StringName property; diff --git a/bt/tasks/actions/bt_pause_animation.cpp b/bt/tasks/scene/bt_pause_animation.cpp similarity index 100% rename from bt/tasks/actions/bt_pause_animation.cpp rename to bt/tasks/scene/bt_pause_animation.cpp diff --git a/bt/tasks/actions/bt_pause_animation.h b/bt/tasks/scene/bt_pause_animation.h similarity index 98% rename from bt/tasks/actions/bt_pause_animation.h rename to bt/tasks/scene/bt_pause_animation.h index bc319a1..4424e77 100644 --- a/bt/tasks/actions/bt_pause_animation.h +++ b/bt/tasks/scene/bt_pause_animation.h @@ -20,6 +20,7 @@ class BTPauseAnimation : public BTAction { GDCLASS(BTPauseAnimation, BTAction); + TASK_CATEGORY(Scene); private: Ref animation_player_param; diff --git a/bt/tasks/actions/bt_play_animation.cpp b/bt/tasks/scene/bt_play_animation.cpp similarity index 100% rename from bt/tasks/actions/bt_play_animation.cpp rename to bt/tasks/scene/bt_play_animation.cpp diff --git a/bt/tasks/actions/bt_play_animation.h b/bt/tasks/scene/bt_play_animation.h similarity index 97% rename from bt/tasks/actions/bt_play_animation.h rename to bt/tasks/scene/bt_play_animation.h index 5b85820..4c277c2 100644 --- a/bt/tasks/actions/bt_play_animation.h +++ b/bt/tasks/scene/bt_play_animation.h @@ -20,6 +20,7 @@ class BTPlayAnimation : public BTAction { GDCLASS(BTPlayAnimation, BTAction); + TASK_CATEGORY(Scene); private: Ref animation_player_param; diff --git a/bt/tasks/actions/bt_set_agent_property.cpp b/bt/tasks/scene/bt_set_agent_property.cpp similarity index 100% rename from bt/tasks/actions/bt_set_agent_property.cpp rename to bt/tasks/scene/bt_set_agent_property.cpp diff --git a/bt/tasks/actions/bt_set_agent_property.h b/bt/tasks/scene/bt_set_agent_property.h similarity index 95% rename from bt/tasks/actions/bt_set_agent_property.h rename to bt/tasks/scene/bt_set_agent_property.h index c218547..8df6389 100644 --- a/bt/tasks/actions/bt_set_agent_property.h +++ b/bt/tasks/scene/bt_set_agent_property.h @@ -18,6 +18,7 @@ class BTSetAgentProperty : public BTAction { GDCLASS(BTSetAgentProperty, BTAction); + TASK_CATEGORY(Scene); private: StringName property; diff --git a/bt/tasks/actions/bt_stop_animation.cpp b/bt/tasks/scene/bt_stop_animation.cpp similarity index 100% rename from bt/tasks/actions/bt_stop_animation.cpp rename to bt/tasks/scene/bt_stop_animation.cpp diff --git a/bt/tasks/actions/bt_stop_animation.h b/bt/tasks/scene/bt_stop_animation.h similarity index 96% rename from bt/tasks/actions/bt_stop_animation.h rename to bt/tasks/scene/bt_stop_animation.h index dbcd951..217e10d 100644 --- a/bt/tasks/actions/bt_stop_animation.h +++ b/bt/tasks/scene/bt_stop_animation.h @@ -20,6 +20,7 @@ class BTStopAnimation : public BTAction { GDCLASS(BTStopAnimation, BTAction); + TASK_CATEGORY(Scene); private: Ref animation_player_param; diff --git a/bt/tasks/actions/bt_console_print.cpp b/bt/tasks/utility/bt_console_print.cpp similarity index 100% rename from bt/tasks/actions/bt_console_print.cpp rename to bt/tasks/utility/bt_console_print.cpp diff --git a/bt/tasks/actions/bt_console_print.h b/bt/tasks/utility/bt_console_print.h similarity index 95% rename from bt/tasks/actions/bt_console_print.h rename to bt/tasks/utility/bt_console_print.h index bdf0e9c..dc8d718 100644 --- a/bt/tasks/actions/bt_console_print.h +++ b/bt/tasks/utility/bt_console_print.h @@ -18,6 +18,7 @@ class BTConsolePrint : public BTAction { GDCLASS(BTConsolePrint, BTAction); + TASK_CATEGORY(Utility); private: String text; diff --git a/bt/tasks/actions/bt_fail.cpp b/bt/tasks/utility/bt_fail.cpp similarity index 100% rename from bt/tasks/actions/bt_fail.cpp rename to bt/tasks/utility/bt_fail.cpp diff --git a/bt/tasks/actions/bt_fail.h b/bt/tasks/utility/bt_fail.h similarity index 92% rename from bt/tasks/actions/bt_fail.h rename to bt/tasks/utility/bt_fail.h index cf64e7d..e1cbb24 100644 --- a/bt/tasks/actions/bt_fail.h +++ b/bt/tasks/utility/bt_fail.h @@ -16,6 +16,7 @@ class BTFail : public BTAction { GDCLASS(BTFail, BTAction); + TASK_CATEGORY(Utility); protected: virtual int _tick(double p_delta) override; diff --git a/bt/tasks/actions/bt_random_wait.cpp b/bt/tasks/utility/bt_random_wait.cpp similarity index 100% rename from bt/tasks/actions/bt_random_wait.cpp rename to bt/tasks/utility/bt_random_wait.cpp diff --git a/bt/tasks/actions/bt_random_wait.h b/bt/tasks/utility/bt_random_wait.h similarity index 95% rename from bt/tasks/actions/bt_random_wait.h rename to bt/tasks/utility/bt_random_wait.h index ce65c90..5490f6c 100644 --- a/bt/tasks/actions/bt_random_wait.h +++ b/bt/tasks/utility/bt_random_wait.h @@ -16,6 +16,7 @@ class BTRandomWait : public BTAction { GDCLASS(BTRandomWait, BTAction); + TASK_CATEGORY(Utility); private: double min_duration = 1.0; diff --git a/bt/tasks/actions/bt_wait.cpp b/bt/tasks/utility/bt_wait.cpp similarity index 100% rename from bt/tasks/actions/bt_wait.cpp rename to bt/tasks/utility/bt_wait.cpp diff --git a/bt/tasks/actions/bt_wait.h b/bt/tasks/utility/bt_wait.h similarity index 94% rename from bt/tasks/actions/bt_wait.h rename to bt/tasks/utility/bt_wait.h index 3043449..9824f9b 100644 --- a/bt/tasks/actions/bt_wait.h +++ b/bt/tasks/utility/bt_wait.h @@ -16,6 +16,7 @@ class BTWait : public BTAction { GDCLASS(BTWait, BTAction); + TASK_CATEGORY(Utility); private: double duration = 1.0; diff --git a/bt/tasks/actions/bt_wait_ticks.cpp b/bt/tasks/utility/bt_wait_ticks.cpp similarity index 100% rename from bt/tasks/actions/bt_wait_ticks.cpp rename to bt/tasks/utility/bt_wait_ticks.cpp diff --git a/bt/tasks/actions/bt_wait_ticks.h b/bt/tasks/utility/bt_wait_ticks.h similarity index 94% rename from bt/tasks/actions/bt_wait_ticks.h rename to bt/tasks/utility/bt_wait_ticks.h index 8271bd4..2e5ae50 100644 --- a/bt/tasks/actions/bt_wait_ticks.h +++ b/bt/tasks/utility/bt_wait_ticks.h @@ -16,6 +16,7 @@ class BTWaitTicks : public BTAction { GDCLASS(BTWaitTicks, BTAction); + TASK_CATEGORY(Utility); private: int num_ticks = 1; diff --git a/editor/limbo_ai_editor_plugin.cpp b/editor/limbo_ai_editor_plugin.cpp index 39f9275..3a5a870 100644 --- a/editor/limbo_ai_editor_plugin.cpp +++ b/editor/limbo_ai_editor_plugin.cpp @@ -14,773 +14,24 @@ #include "limbo_ai_editor_plugin.h" #include "action_banner.h" -#include "modules/limboai/bt/behavior_tree.h" -#include "modules/limboai/bt/tasks/bt_action.h" #include "modules/limboai/bt/tasks/bt_comment.h" -#include "modules/limboai/bt/tasks/bt_task.h" -#include "modules/limboai/bt/tasks/composites/bt_parallel.h" #include "modules/limboai/bt/tasks/composites/bt_selector.h" -#include "modules/limboai/bt/tasks/composites/bt_sequence.h" #include "modules/limboai/editor/debugger/limbo_debugger_plugin.h" #include "modules/limboai/util/limbo_utility.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/math/math_defs.h" -#include "core/math/vector2.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/object/undo_redo.h" -#include "core/os/memory.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/variant/array.h" -#include "core/variant/callable.h" -#include "core/variant/dictionary.h" -#include "core/variant/variant.h" #include "editor/debugger/editor_debugger_node.h" #include "editor/debugger/script_editor_debugger.h" #include "editor/editor_file_system.h" #include "editor/editor_help.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/editor_undo_redo_manager.h" #include "editor/inspector_dock.h" #include "editor/plugins/script_editor_plugin.h" #include "editor/project_settings_editor.h" -#include "scene/gui/box_container.h" -#include "scene/gui/button.h" -#include "scene/gui/control.h" -#include "scene/gui/file_dialog.h" -#include "scene/gui/flow_container.h" -#include "scene/gui/label.h" -#include "scene/gui/line_edit.h" -#include "scene/gui/popup_menu.h" -#include "scene/gui/scroll_container.h" #include "scene/gui/separator.h" -#include "scene/gui/split_container.h" -#include "scene/gui/tree.h" -#include "servers/display_server.h" - -//**** TaskTree - -TreeItem *TaskTree::_create_tree(const Ref &p_task, TreeItem *p_parent, int p_idx) { - ERR_FAIL_COND_V(p_task.is_null(), nullptr); - TreeItem *item = tree->create_item(p_parent, p_idx); - item->set_metadata(0, p_task); - // p_task->connect("changed"...) - for (int i = 0; i < p_task->get_child_count(); i++) { - _create_tree(p_task->get_child(i), item); - } - _update_item(item); - return item; -} - -void TaskTree::_update_item(TreeItem *p_item) { - if (p_item == nullptr) { - return; - } - 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->is_class_ptr(BTComment::get_class_ptr_static())) { - p_item->set_custom_font(0, (get_theme_font(SNAME("doc_italic"), SNAME("EditorFonts")))); - p_item->set_custom_color(0, get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))); - } else if (task->get_custom_name().is_empty()) { - p_item->set_custom_font(0, nullptr); - p_item->clear_custom_color(0); - } else { - p_item->set_custom_font(0, (get_theme_font(SNAME("bold"), SNAME("EditorFonts")))); - // p_item->set_custom_color(0, get_theme_color(SNAME("warning_color"), SNAME("Editor"))); - } - String type_arg; - if (task->get_script_instance() && !task->get_script_instance()->get_script()->get_path().is_empty()) { - type_arg = task->get_script_instance()->get_script()->get_path(); - } else { - type_arg = task->get_class(); - } - p_item->set_icon(0, LimboUtility::get_singleton()->get_task_icon(type_arg)); - p_item->set_icon_max_width(0, 16 * EDSCALE); - p_item->set_editable(0, false); - - for (int i = 0; i < p_item->get_button_count(0); i++) { - p_item->erase_button(0, i); - } - - PackedStringArray warnings = task->get_configuration_warnings(); - String warning_text; - for (int j = 0; j < warnings.size(); j++) { - if (j > 0) { - warning_text += "\n"; - } - warning_text += warnings[j]; - } - if (!warning_text.is_empty()) { - p_item->add_button(0, get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons")), 0, false, warning_text); - } - - // TODO: Update probabilities. -} - -void TaskTree::_update_tree() { - Ref sel; - if (tree->get_selected()) { - sel = tree->get_selected()->get_metadata(0); - } - - tree->clear(); - if (bt.is_null()) { - return; - } - - if (bt->get_root_task().is_valid()) { - _create_tree(bt->get_root_task(), nullptr); - } - - TreeItem *item = _find_item(sel); - if (item) { - item->select(0); - } -} - -TreeItem *TaskTree::_find_item(const Ref &p_task) const { - if (p_task.is_null()) { - return nullptr; - } - TreeItem *item = tree->get_root(); - List stack; - while (item && item->get_metadata(0) != p_task) { - if (item->get_child_count() > 0) { - stack.push_back(item->get_first_child()); - } - item = item->get_next(); - if (item == nullptr && !stack.is_empty()) { - item = stack.front()->get(); - stack.pop_front(); - } - } - return item; -} - -void TaskTree::_on_item_mouse_selected(const Vector2 &p_pos, int p_button_index) { - if (p_button_index == 2) { - emit_signal(SNAME("rmb_pressed"), get_screen_position() + p_pos); - } -} - -void TaskTree::_on_item_selected() { - Callable on_task_changed = callable_mp(this, &TaskTree::_on_task_changed); - if (last_selected.is_valid()) { - update_task(last_selected); - if (last_selected->is_connected("changed", on_task_changed)) { - last_selected->disconnect("changed", on_task_changed); - } - } - last_selected = get_selected(); - last_selected->connect("changed", on_task_changed); - emit_signal(SNAME("task_selected"), last_selected); -} - -void TaskTree::_on_item_double_clicked() { - emit_signal(SNAME("task_double_clicked")); -} - -void TaskTree::_on_task_changed() { - _update_item(tree->get_selected()); -} - -void TaskTree::load_bt(const Ref &p_behavior_tree) { - ERR_FAIL_COND_MSG(p_behavior_tree.is_null(), "Tried to load a null tree."); - - Callable on_task_changed = callable_mp(this, &TaskTree::_on_task_changed); - if (last_selected.is_valid() && last_selected->is_connected("changed", on_task_changed)) { - last_selected->disconnect("changed", on_task_changed); - } - - bt = p_behavior_tree; - tree->clear(); - if (bt->get_root_task().is_valid()) { - _create_tree(bt->get_root_task(), nullptr); - } -} - -void TaskTree::unload() { - Callable on_task_changed = callable_mp(this, &TaskTree::_on_task_changed); - if (last_selected.is_valid() && last_selected->is_connected("changed", on_task_changed)) { - last_selected->disconnect("changed", on_task_changed); - } - - bt->unreference(); - tree->clear(); -} - -void TaskTree::update_task(const Ref &p_task) { - ERR_FAIL_COND(p_task.is_null()); - TreeItem *item = _find_item(p_task); - if (item) { - _update_item(item); - } -} - -Ref TaskTree::get_selected() const { - if (tree->get_selected()) { - return tree->get_selected()->get_metadata(0); - } - return nullptr; -} - -void TaskTree::deselect() { - TreeItem *sel = tree->get_selected(); - if (sel) { - sel->deselect(0); - } -} - -Variant TaskTree::_get_drag_data_fw(const Point2 &p_point) { - if (editable && tree->get_item_at_position(p_point)) { - Dictionary drag_data; - drag_data["type"] = "task"; - drag_data["task"] = tree->get_item_at_position(p_point)->get_metadata(0); - tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN | Tree::DROP_MODE_ON_ITEM); - return drag_data; - } - return Variant(); -} - -bool TaskTree::_can_drop_data_fw(const Point2 &p_point, const Variant &p_data) const { - if (!editable) { - return false; - } - - Dictionary d = p_data; - if (!d.has("type") || !d.has("task")) { - return false; - } - - int section = tree->get_drop_section_at_position(p_point); - TreeItem *item = tree->get_item_at_position(p_point); - if (!item || section < -1 || (section == -1 && !item->get_parent())) { - return false; - } - - if (String(d["type"]) == "task") { - Ref task = d["task"]; - const Ref to_task = item->get_metadata(0); - if (task != to_task && !to_task->is_descendant_of(task)) { - return true; - } - } - - return false; -} - -void TaskTree::_drop_data_fw(const Point2 &p_point, const Variant &p_data) { - Dictionary d = p_data; - TreeItem *item = tree->get_item_at_position(p_point); - if (item && d.has("task")) { - Ref task = d["task"]; - emit_signal(SNAME("task_dragged"), task, item->get_metadata(0), tree->get_drop_section_at_position(p_point)); - } -} - -void TaskTree::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_THEME_CHANGED: { - _update_tree(); - } break; - } -} - -void TaskTree::_bind_methods() { - ClassDB::bind_method(D_METHOD("load_bt", "p_behavior_tree"), &TaskTree::load_bt); - ClassDB::bind_method(D_METHOD("get_bt"), &TaskTree::get_bt); - ClassDB::bind_method(D_METHOD("update_tree"), &TaskTree::update_tree); - ClassDB::bind_method(D_METHOD("update_task", "p_task"), &TaskTree::update_task); - 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); - - ADD_SIGNAL(MethodInfo("rmb_pressed")); - ADD_SIGNAL(MethodInfo("task_selected")); - ADD_SIGNAL(MethodInfo("task_double_clicked")); - ADD_SIGNAL(MethodInfo("task_dragged", - PropertyInfo(Variant::OBJECT, "p_task", PROPERTY_HINT_RESOURCE_TYPE, "BTTask"), - PropertyInfo(Variant::OBJECT, "p_to_task", PROPERTY_HINT_RESOURCE_TYPE, "BTTask"), - PropertyInfo(Variant::INT, "p_type"))); -} - -TaskTree::TaskTree() { - editable = true; - - tree = memnew(Tree); - add_child(tree); - tree->set_columns(2); - tree->set_column_expand(0, true); - tree->set_column_expand(1, false); - 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_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(callable_mp(this, &TaskTree::_get_drag_data_fw), callable_mp(this, &TaskTree::_can_drop_data_fw), callable_mp(this, &TaskTree::_drop_data_fw)); -} - -TaskTree::~TaskTree() { - Callable on_task_changed = callable_mp(this, &TaskTree::_on_task_changed); - if (last_selected.is_valid() && last_selected->is_connected("changed", on_task_changed)) { - last_selected->disconnect("changed", on_task_changed); - } -} - -//**** TaskTree ^ - -//**** TaskButton - -Control *TaskButton::make_custom_tooltip(const String &p_text) const { - EditorHelpBit *help_bit = memnew(EditorHelpBit); - help_bit->get_rich_text()->set_custom_minimum_size(Size2(360 * EDSCALE, 1)); - - String help_text; - if (!p_text.is_empty()) { - help_text = p_text; - } else { - help_text = "[i]" + TTR("No description.") + "[/i]"; - } - - help_bit->set_text(help_text); - - return help_bit; -} - -//**** TaskButton ^ - -//**** TaskSection - -void TaskSection::_on_task_button_pressed(const String &p_task) { - emit_signal(SNAME("task_button_pressed"), p_task); -} - -void TaskSection::_on_task_button_gui_input(const Ref &p_event, const String &p_task) { - if (!p_event->is_pressed()) { - return; - } - - Ref mb = p_event; - if (mb.is_valid() && mb->get_button_index() == MouseButton::RIGHT) { - emit_signal(SNAME("task_button_rmb"), p_task); - } -} - -void TaskSection::_on_header_pressed() { - set_collapsed(!is_collapsed()); -} - -void TaskSection::set_filter(String p_filter_text) { - int num_hidden = 0; - if (p_filter_text.is_empty()) { - for (int i = 0; i < tasks_container->get_child_count(); i++) { - Object::cast_to