Compare commits

...

6 Commits

Author SHA1 Message Date
Serhii Snitsaruk 3af2374251
Merge c498fd90e5 into a2a62f636b 2024-08-02 11:48:39 -04:00
Serhii Snitsaruk a2a62f636b
Merge pull request #180 from limbonaut/fix-changed-already-connected
Fix error if `changed` signal is already connected in several tasks
2024-08-02 14:43:21 +02:00
Serhii Snitsaruk ce1867be7a
Fix error if `changed` signal is already connected to a BBParam in a bunch of tasks 2024-08-02 10:07:42 +02:00
Serhii Snitsaruk 09185211ff
Merge pull request #177 from limbonaut/hide-update-mode
Hide `update_mode` property for non-root HSMs
2024-07-31 15:26:45 +02:00
Serhii Snitsaruk 9e79183579
Update demo import 2024-07-31 14:50:56 +02:00
Serhii Snitsaruk bed04dbf87
Hide update_mode for non-root HSMs 2024-07-31 14:50:04 +02:00
17 changed files with 46 additions and 24 deletions

View File

@ -24,8 +24,9 @@ void BTCheckVar::set_check_type(LimboUtility::CheckType p_check_type) {
void BTCheckVar::set_value(const Ref<BBVariant> &p_value) { void BTCheckVar::set_value(const Ref<BBVariant> &p_value) {
value = p_value; value = p_value;
emit_changed(); emit_changed();
if (Engine::get_singleton()->is_editor_hint() && value.is_valid()) { if (Engine::get_singleton()->is_editor_hint() && value.is_valid() &&
value->connect(LW_NAME(changed), Callable(this, LW_NAME(emit_changed))); !value->is_connected(LW_NAME(changed), callable_mp((Resource *)this, &Resource::emit_changed))) {
value->connect(LW_NAME(changed), callable_mp((Resource *)this, &Resource::emit_changed));
} }
} }

View File

@ -48,8 +48,9 @@ void BTSetVar::set_variable(const StringName &p_variable) {
void BTSetVar::set_value(const Ref<BBVariant> &p_value) { void BTSetVar::set_value(const Ref<BBVariant> &p_value) {
value = p_value; value = p_value;
emit_changed(); emit_changed();
if (Engine::get_singleton()->is_editor_hint() && value.is_valid()) { if (Engine::get_singleton()->is_editor_hint() && value.is_valid() &&
value->connect(LW_NAME(changed), Callable(this, LW_NAME(emit_changed))); !value->is_connected(LW_NAME(changed), callable_mp((Resource *)this, &Resource::emit_changed))) {
value->connect(LW_NAME(changed), callable_mp((Resource *)this, &Resource::emit_changed));
} }
} }

View File

@ -16,8 +16,9 @@
void BTAwaitAnimation::set_animation_player(Ref<BBNode> p_animation_player) { void BTAwaitAnimation::set_animation_player(Ref<BBNode> p_animation_player) {
animation_player_param = p_animation_player; animation_player_param = p_animation_player;
emit_changed(); emit_changed();
if (Engine::get_singleton()->is_editor_hint() && animation_player_param.is_valid()) { if (Engine::get_singleton()->is_editor_hint() && animation_player_param.is_valid() &&
animation_player_param->connect(LW_NAME(changed), Callable(this, LW_NAME(emit_changed))); !animation_player_param->is_connected(LW_NAME(changed), callable_mp((Resource *)this, &Resource::emit_changed))) {
animation_player_param->connect(LW_NAME(changed), callable_mp((Resource *)this, &Resource::emit_changed));
} }
} }

View File

@ -24,8 +24,9 @@ void BTCheckAgentProperty::set_check_type(LimboUtility::CheckType p_check_type)
void BTCheckAgentProperty::set_value(Ref<BBVariant> p_value) { void BTCheckAgentProperty::set_value(Ref<BBVariant> p_value) {
value = p_value; value = p_value;
emit_changed(); emit_changed();
if (Engine::get_singleton()->is_editor_hint() && value.is_valid()) { if (Engine::get_singleton()->is_editor_hint() && value.is_valid() &&
value->connect(LW_NAME(changed), Callable(this, LW_NAME(emit_changed))); !value->is_connected(LW_NAME(changed), callable_mp((Resource *)this, &Resource::emit_changed))) {
value->connect(LW_NAME(changed), callable_mp((Resource *)this, &Resource::emit_changed));
} }
} }

View File

@ -16,8 +16,9 @@
void BTPauseAnimation::set_animation_player(Ref<BBNode> p_animation_player) { void BTPauseAnimation::set_animation_player(Ref<BBNode> p_animation_player) {
animation_player_param = p_animation_player; animation_player_param = p_animation_player;
emit_changed(); emit_changed();
if (Engine::get_singleton()->is_editor_hint() && animation_player_param.is_valid()) { if (Engine::get_singleton()->is_editor_hint() && animation_player_param.is_valid() &&
animation_player_param->connect(LW_NAME(changed), Callable(this, LW_NAME(emit_changed))); !animation_player_param->is_connected(LW_NAME(changed), callable_mp((Resource *)this, &Resource::emit_changed))) {
animation_player_param->connect(LW_NAME(changed), callable_mp((Resource *)this, &Resource::emit_changed));
} }
} }

View File

@ -16,8 +16,9 @@
void BTPlayAnimation::set_animation_player(Ref<BBNode> p_animation_player) { void BTPlayAnimation::set_animation_player(Ref<BBNode> p_animation_player) {
animation_player_param = p_animation_player; animation_player_param = p_animation_player;
emit_changed(); emit_changed();
if (Engine::get_singleton()->is_editor_hint() && animation_player_param.is_valid()) { if (Engine::get_singleton()->is_editor_hint() && animation_player_param.is_valid() &&
animation_player_param->connect(LW_NAME(changed), Callable(this, LW_NAME(emit_changed))); !animation_player_param->is_connected(LW_NAME(changed), callable_mp((Resource *)this, &Resource::emit_changed))) {
animation_player_param->connect(LW_NAME(changed), callable_mp((Resource *)this, &Resource::emit_changed));
} }
} }

View File

@ -19,8 +19,9 @@ void BTSetAgentProperty::set_property(StringName p_prop) {
void BTSetAgentProperty::set_value(Ref<BBVariant> p_value) { void BTSetAgentProperty::set_value(Ref<BBVariant> p_value) {
value = p_value; value = p_value;
emit_changed(); emit_changed();
if (Engine::get_singleton()->is_editor_hint() && value.is_valid()) { if (Engine::get_singleton()->is_editor_hint() && value.is_valid() &&
value->connect(LW_NAME(changed), Callable(this, LW_NAME(emit_changed))); !value->is_connected(LW_NAME(changed), callable_mp((Resource *)this, &Resource::emit_changed))) {
value->connect(LW_NAME(changed), callable_mp((Resource *)this, &Resource::emit_changed));
} }
} }

View File

@ -16,8 +16,9 @@
void BTStopAnimation::set_animation_player(Ref<BBNode> p_animation_player) { void BTStopAnimation::set_animation_player(Ref<BBNode> p_animation_player) {
animation_player_param = p_animation_player; animation_player_param = p_animation_player;
emit_changed(); emit_changed();
if (Engine::get_singleton()->is_editor_hint() && animation_player_param.is_valid()) { if (Engine::get_singleton()->is_editor_hint() && animation_player_param.is_valid() &&
animation_player_param->connect(LW_NAME(changed), Callable(this, LW_NAME(emit_changed))); !animation_player_param->is_connected(LW_NAME(changed), callable_mp((Resource *)this, &Resource::emit_changed))) {
animation_player_param->connect(LW_NAME(changed), callable_mp((Resource *)this, &Resource::emit_changed));
} }
} }

View File

@ -28,8 +28,9 @@ void BTCallMethod::set_method(const StringName &p_method_name) {
void BTCallMethod::set_node_param(const Ref<BBNode> &p_object) { void BTCallMethod::set_node_param(const Ref<BBNode> &p_object) {
node_param = p_object; node_param = p_object;
emit_changed(); emit_changed();
if (Engine::get_singleton()->is_editor_hint() && node_param.is_valid()) { if (Engine::get_singleton()->is_editor_hint() && node_param.is_valid() &&
node_param->connect(LW_NAME(changed), Callable(this, LW_NAME(emit_changed))); !node_param->is_connected(LW_NAME(changed), callable_mp((Resource *)this, &Resource::emit_changed))) {
node_param->connect(LW_NAME(changed), callable_mp((Resource *)this, &Resource::emit_changed));
} }
} }

View File

@ -29,8 +29,9 @@ void BTEvaluateExpression::set_expression_string(const String &p_expression_stri
void BTEvaluateExpression::set_node_param(Ref<BBNode> p_object) { void BTEvaluateExpression::set_node_param(Ref<BBNode> p_object) {
node_param = p_object; node_param = p_object;
emit_changed(); emit_changed();
if (Engine::get_singleton()->is_editor_hint() && node_param.is_valid()) { if (Engine::get_singleton()->is_editor_hint() && node_param.is_valid() &&
node_param->connect(LW_NAME(changed), Callable(this, LW_NAME(emit_changed))); !node_param->is_connected(LW_NAME(changed), callable_mp((Resource *)this, &Resource::emit_changed))) {
node_param->connect(LW_NAME(changed), callable_mp((Resource *)this, &Resource::emit_changed));
} }
} }

View File

@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/junction_bold.otf-4db2200a8b1a6423bafe2a4e7c7
Rendering=null Rendering=null
antialiasing=1 antialiasing=1
generate_mipmaps=false generate_mipmaps=false
disable_embedded_bitmaps=true
multichannel_signed_distance_field=false multichannel_signed_distance_field=false
msdf_pixel_range=8 msdf_pixel_range=8
msdf_size=48 msdf_size=48

View File

@ -15,6 +15,7 @@ dest_files=["res://.godot/imported/knewave_regular.ttf-955953b059f713782c7b07e66
Rendering=null Rendering=null
antialiasing=1 antialiasing=1
generate_mipmaps=false generate_mipmaps=false
disable_embedded_bitmaps=true
multichannel_signed_distance_field=false multichannel_signed_distance_field=false
msdf_pixel_range=8 msdf_pixel_range=8
msdf_size=48 msdf_size=48

View File

@ -234,18 +234,18 @@ unique_name_in_owner = true
custom_minimum_size = Vector2(0, 140) custom_minimum_size = Vector2(0, 140)
layout_mode = 2 layout_mode = 2
size_flags_vertical = 3 size_flags_vertical = 3
theme_override_font_sizes/bold_italics_font_size = 20
theme_override_font_sizes/italics_font_size = 20
theme_override_font_sizes/mono_font_size = 20
theme_override_font_sizes/normal_font_size = 20 theme_override_font_sizes/normal_font_size = 20
theme_override_font_sizes/bold_font_size = 20 theme_override_font_sizes/bold_font_size = 20
theme_override_font_sizes/italics_font_size = 20
theme_override_font_sizes/bold_italics_font_size = 20
theme_override_font_sizes/mono_font_size = 20
bbcode_enabled = true bbcode_enabled = true
text = "[b]Behavior Trees[/b] are composed of tasks that represent specific actions or decision-making rules. Tasks can be broadly categorized into two main types: control tasks and leaf tasks. Control tasks determine the execution flow within the tree. They include Sequence, Selector, and Invert. Leaf tasks represent specific actions to perform, like moving or attacking, or conditions that need to be checked. The BTTask class provides the foundation for various building blocks of the Behavior Trees. BT tasks can share data with the help of the Blackboard." text = "[b]Behavior Trees[/b] are composed of tasks that represent specific actions or decision-making rules. Tasks can be broadly categorized into two main types: control tasks and leaf tasks. Control tasks determine the execution flow within the tree. They include Sequence, Selector, and Invert. Leaf tasks represent specific actions to perform, like moving or attacking, or conditions that need to be checked. The BTTask class provides the foundation for various building blocks of the Behavior Trees. BT tasks can share data with the help of the Blackboard."
fit_content = true fit_content = true
[node name="CodePopup" type="PopupPanel" parent="UI Layer/Control"] [node name="CodePopup" type="PopupPanel" parent="UI Layer/Control"]
unique_name_in_owner = true unique_name_in_owner = true
position = Vector2i(135, 60) position = Vector2i(0, 60)
size = Vector2i(1024, 708) size = Vector2i(1024, 708)
visible = true visible = true

View File

@ -253,6 +253,13 @@ void LimboHSM::_initialize(Node *p_agent, const Ref<Blackboard> &p_blackboard) {
} }
} }
void LimboHSM::_validate_property(PropertyInfo &p_property) const {
if (p_property.name == LW_NAME(update_mode) && !is_root()) {
// Hide update_mode for non-root HSMs.
p_property.usage = PROPERTY_USAGE_NONE;
}
}
void LimboHSM::_notification(int p_what) { void LimboHSM::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_POST_ENTER_TREE: { case NOTIFICATION_POST_ENTER_TREE: {

View File

@ -64,6 +64,7 @@ protected:
static void _bind_methods(); static void _bind_methods();
void _notification(int p_what); void _notification(int p_what);
void _validate_property(PropertyInfo &p_property) const;
virtual void _initialize(Node *p_agent, const Ref<Blackboard> &p_blackboard) override; virtual void _initialize(Node *p_agent, const Ref<Blackboard> &p_blackboard) override;
virtual bool _dispatch(const StringName &p_event, const Variant &p_cargo = Variant()) override; virtual bool _dispatch(const StringName &p_event, const Variant &p_cargo = Variant()) override;

View File

@ -156,6 +156,7 @@ LimboStringNames::LimboStringNames() {
Tools = SN("Tools"); Tools = SN("Tools");
Tree = SN("Tree"); Tree = SN("Tree");
TripleBar = SN("TripleBar"); TripleBar = SN("TripleBar");
update_mode = SN("update_mode");
update_task = SN("update_task"); update_task = SN("update_task");
update_tree = SN("update_tree"); update_tree = SN("update_tree");
updated = SN("updated"); updated = SN("updated");

View File

@ -173,6 +173,7 @@ public:
StringName Tools; StringName Tools;
StringName Tree; StringName Tree;
StringName TripleBar; StringName TripleBar;
StringName update_mode;
StringName update_task; StringName update_task;
StringName update_tree; StringName update_tree;
StringName updated; StringName updated;