From d66f1e83fdd768aeee7aed24ee85984f07bfc86e Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Mon, 4 Mar 2024 16:55:08 +0100 Subject: [PATCH] Refactor BlackboardPlan to use StringName Also update demo BTs. --- blackboard/blackboard_plan.cpp | 79 ++++++++++--------- blackboard/blackboard_plan.h | 20 ++--- demo/demo/ai/trees/01_agent_melee_simple.tres | 2 +- demo/demo/ai/trees/02_agent_charger.tres | 4 +- demo/demo/ai/trees/03_agent_imp.tres | 2 +- demo/demo/ai/trees/04_agent_skirmisher.tres | 6 +- demo/demo/ai/trees/05_agent_ranged.tres | 4 +- demo/demo/ai/trees/06_agent_melee_combo.tres | 4 +- .../demo/ai/trees/07_agent_melee_nuanced.tres | 4 +- demo/demo/ai/trees/08_agent_demon.tres | 2 +- demo/demo/ai/trees/09_agent_summoner.tres | 10 +-- .../tutorial_trees/tutorial_01_welcome.tres | 4 +- .../tutorial_02_introduction.tres | 8 +- .../ai/tutorial_trees/tutorial_03_types.tres | 8 +- .../tutorial_trees/tutorial_04_sequence.tres | 6 +- .../tutorial_trees/tutorial_05_selector.tres | 10 +-- .../tutorial_06_decorators.tres | 14 ++-- .../tutorial_07_more_decorators.tres | 18 ++--- .../tutorial_08_final_touch.tres | 28 +++---- demo/demo/scenes/showcase.tscn | 4 +- 20 files changed, 119 insertions(+), 118 deletions(-) diff --git a/blackboard/blackboard_plan.cpp b/blackboard/blackboard_plan.cpp index b6375f5..87dcf99 100644 --- a/blackboard/blackboard_plan.cpp +++ b/blackboard/blackboard_plan.cpp @@ -12,22 +12,22 @@ #include "blackboard_plan.h" bool BlackboardPlan::_set(const StringName &p_name, const Variant &p_value) { - String prop_name = p_name; + String name_str = p_name; // * Editor - if (var_map.has(prop_name)) { - var_map[prop_name].set_value(p_value); - if (base.is_valid() && p_value == base->get_var(prop_name).get_value()) { + if (var_map.has(p_name)) { + var_map[p_name].set_value(p_value); + if (base.is_valid() && p_value == base->get_var(p_name).get_value()) { // When user pressed reset property button in inspector... - var_map[prop_name].reset_value_changed(); + var_map[p_name].reset_value_changed(); } return true; } // * Storage - if (prop_name.begins_with("var/")) { - String var_name = prop_name.get_slicec('/', 1); - String what = prop_name.get_slicec('/', 2); + if (name_str.begins_with("var/")) { + StringName var_name = name_str.get_slicec('/', 1); + String what = name_str.get_slicec('/', 2); if (!var_map.has(var_name) && what == "name") { add_var(var_name, BBVariable()); } @@ -51,21 +51,21 @@ bool BlackboardPlan::_set(const StringName &p_name, const Variant &p_value) { } bool BlackboardPlan::_get(const StringName &p_name, Variant &r_ret) const { - String prop_name = p_name; + String name_str = p_name; // * Editor - if (var_map.has(prop_name)) { - r_ret = var_map[prop_name].get_value(); + if (var_map.has(p_name)) { + r_ret = var_map[p_name].get_value(); return true; } // * Storage - if (!prop_name.begins_with("var/")) { + if (!name_str.begins_with("var/")) { return false; } - String var_name = prop_name.get_slicec('/', 1); - String what = prop_name.get_slicec('/', 2); + StringName var_name = name_str.get_slicec('/', 1); + String what = name_str.get_slicec('/', 2); ERR_FAIL_COND_V(!var_map.has(var_name), false); if (what == "name") { @@ -83,7 +83,7 @@ bool BlackboardPlan::_get(const StringName &p_name, Variant &r_ret) const { } void BlackboardPlan::_get_property_list(List *p_list) const { - for (const Pair &p : var_list) { + for (const Pair &p : var_list) { String var_name = p.first; BBVariable var = p.second; @@ -119,58 +119,59 @@ void BlackboardPlan::set_base_plan(const Ref &p_base) { notify_property_list_changed(); } -void BlackboardPlan::add_var(const String &p_name, const BBVariable &p_var) { +void BlackboardPlan::add_var(const StringName &p_name, const BBVariable &p_var) { ERR_FAIL_COND(var_map.has(p_name)); var_map.insert(p_name, p_var); - var_list.push_back(Pair(p_name, p_var)); + var_list.push_back(Pair(p_name, p_var)); notify_property_list_changed(); emit_changed(); } -void BlackboardPlan::remove_var(const String &p_name) { +void BlackboardPlan::remove_var(const StringName &p_name) { ERR_FAIL_COND(!var_map.has(p_name)); - var_list.erase(Pair(p_name, var_map[p_name])); + var_list.erase(Pair(p_name, var_map[p_name])); var_map.erase(p_name); notify_property_list_changed(); emit_changed(); } -BBVariable BlackboardPlan::get_var(const String &p_name) { +BBVariable BlackboardPlan::get_var(const StringName &p_name) { ERR_FAIL_COND_V(!var_map.has(p_name), BBVariable()); return var_map.get(p_name); } -Pair BlackboardPlan::get_var_by_index(int p_index) { - Pair ret; +Pair BlackboardPlan::get_var_by_index(int p_index) { + Pair ret; ERR_FAIL_INDEX_V(p_index, (int)var_map.size(), ret); return var_list[p_index]; } PackedStringArray BlackboardPlan::list_vars() const { PackedStringArray ret; - for (const Pair &p : var_list) { + for (const Pair &p : var_list) { ret.append(p.first); } return ret; } -String BlackboardPlan::get_var_name(const BBVariable &p_var) const { - for (const Pair &p : var_list) { +StringName BlackboardPlan::get_var_name(const BBVariable &p_var) const { + for (const Pair &p : var_list) { if (p.second == p_var) { return p.first; } } - return String(); + return StringName(); } -bool BlackboardPlan::is_valid_var_name(const String &p_name) const { - if (p_name.begins_with("resource_")) { +bool BlackboardPlan::is_valid_var_name(const StringName &p_name) const { + String name_str = p_name; + if (name_str.begins_with("resource_")) { return false; } - return p_name.is_valid_identifier() && !var_map.has(p_name); + return name_str.is_valid_identifier() && !var_map.has(p_name); } -void BlackboardPlan::rename_var(const String &p_name, const String &p_new_name) { +void BlackboardPlan::rename_var(const StringName &p_name, const StringName &p_new_name) { if (p_name == p_new_name) { return; } @@ -179,8 +180,8 @@ void BlackboardPlan::rename_var(const String &p_name, const String &p_new_name) ERR_FAIL_COND(!var_map.has(p_name)); BBVariable var = var_map[p_name]; - Pair new_entry(p_new_name, var); - Pair old_entry(p_name, var); + Pair new_entry(p_new_name, var); + Pair old_entry(p_name, var); var_list.find(old_entry)->set(new_entry); var_map.erase(p_name); @@ -198,11 +199,11 @@ void BlackboardPlan::move_var(int p_index, int p_new_index) { return; } - List>::Element *E = var_list.front(); + List>::Element *E = var_list.front(); for (int i = 0; i < p_index; i++) { E = E->next(); } - List>::Element *E2 = var_list.front(); + List>::Element *E2 = var_list.front(); for (int i = 0; i < p_new_index; i++) { E2 = E2->next(); } @@ -224,8 +225,8 @@ void BlackboardPlan::sync_with_base_plan() { bool changed = false; // Sync variables with the base plan. - for (const Pair &p : base->var_list) { - const String &base_name = p.first; + for (const Pair &p : base->var_list) { + const StringName &base_name = p.first; const BBVariable &base_var = p.second; if (!var_map.has(base_name)) { @@ -249,7 +250,7 @@ void BlackboardPlan::sync_with_base_plan() { } // Erase variables that do not exist in the base plan. - for (const Pair &p : var_list) { + for (const Pair &p : var_list) { if (!base->has_var(p.first)) { remove_var(p.first); changed = true; @@ -264,14 +265,14 @@ void BlackboardPlan::sync_with_base_plan() { Ref BlackboardPlan::create_blackboard() { Ref bb = memnew(Blackboard); - for (const Pair &p : var_list) { + for (const Pair &p : var_list) { bb->add_var(p.first, p.second.duplicate()); } return bb; } void BlackboardPlan::populate_blackboard(const Ref &p_blackboard, bool overwrite) { - for (const Pair &p : var_list) { + for (const Pair &p : var_list) { if (p_blackboard->has_var(p.first)) { if (overwrite) { p_blackboard->erase_var(p.first); diff --git a/blackboard/blackboard_plan.h b/blackboard/blackboard_plan.h index b3281f8..25599dd 100644 --- a/blackboard/blackboard_plan.h +++ b/blackboard/blackboard_plan.h @@ -28,8 +28,8 @@ class BlackboardPlan : public Resource { GDCLASS(BlackboardPlan, Resource); private: - List> var_list; - HashMap var_map; + List> var_list; + HashMap var_map; // When base is not null, the plan is considered to be derived from the base plan. // A derived plan can only have variables that exist in the base plan, @@ -49,18 +49,18 @@ public: void set_base_plan(const Ref &p_base); Ref get_base_plan() const { return base; } - void add_var(const String &p_name, const BBVariable &p_var); - void remove_var(const String &p_name); - BBVariable get_var(const String &p_name); - Pair get_var_by_index(int p_index); - bool has_var(const String &p_name) { return var_map.has(p_name); } + void add_var(const StringName &p_name, const BBVariable &p_var); + void remove_var(const StringName &p_name); + BBVariable get_var(const StringName &p_name); + Pair get_var_by_index(int p_index); + bool has_var(const StringName &p_name) { return var_map.has(p_name); } bool is_empty() const { return var_map.is_empty(); } int get_var_count() const { return var_map.size(); } PackedStringArray list_vars() const; - String get_var_name(const BBVariable &p_var) const; - bool is_valid_var_name(const String &p_name) const; - void rename_var(const String &p_name, const String &p_new_name); + StringName get_var_name(const BBVariable &p_var) const; + bool is_valid_var_name(const StringName &p_name) const; + void rename_var(const StringName &p_name, const StringName &p_new_name); void move_var(int p_index, int p_new_index); void sync_with_base_plan(); diff --git a/demo/demo/ai/trees/01_agent_melee_simple.tres b/demo/demo/ai/trees/01_agent_melee_simple.tres index d746640..92a1242 100644 --- a/demo/demo/ai/trees/01_agent_melee_simple.tres +++ b/demo/demo/ai/trees/01_agent_melee_simple.tres @@ -5,7 +5,7 @@ [ext_resource type="Script" path="res://demo/ai/tasks/face_target.gd" id="3_bpmfp"] [sub_resource type="BlackboardPlan" id="BlackboardPlan_46tbn"] -var/speed/name = "speed" +var/speed/name = &"speed" var/speed/type = 3 var/speed/value = 400.0 var/speed/hint = 1 diff --git a/demo/demo/ai/trees/02_agent_charger.tres b/demo/demo/ai/trees/02_agent_charger.tres index f05e03e..19a8b96 100644 --- a/demo/demo/ai/trees/02_agent_charger.tres +++ b/demo/demo/ai/trees/02_agent_charger.tres @@ -7,12 +7,12 @@ [ext_resource type="Script" path="res://demo/ai/tasks/move_forward.gd" id="5_ucvak"] [sub_resource type="BlackboardPlan" id="BlackboardPlan_qd806"] -var/speed/name = "speed" +var/speed/name = &"speed" var/speed/type = 3 var/speed/value = 400.0 var/speed/hint = 1 var/speed/hint_string = "10,1000,10" -var/charge_speed/name = "charge_speed" +var/charge_speed/name = &"charge_speed" var/charge_speed/type = 3 var/charge_speed/value = 1000.0 var/charge_speed/hint = 1 diff --git a/demo/demo/ai/trees/03_agent_imp.tres b/demo/demo/ai/trees/03_agent_imp.tres index 22215d7..1c28464 100644 --- a/demo/demo/ai/trees/03_agent_imp.tres +++ b/demo/demo/ai/trees/03_agent_imp.tres @@ -7,7 +7,7 @@ [ext_resource type="Script" path="res://demo/ai/tasks/face_target.gd" id="5_o4ggh"] [sub_resource type="BlackboardPlan" id="BlackboardPlan_46tbn"] -var/speed/name = "speed" +var/speed/name = &"speed" var/speed/type = 3 var/speed/value = 400.0 var/speed/hint = 1 diff --git a/demo/demo/ai/trees/04_agent_skirmisher.tres b/demo/demo/ai/trees/04_agent_skirmisher.tres index 24d8625..921b62c 100644 --- a/demo/demo/ai/trees/04_agent_skirmisher.tres +++ b/demo/demo/ai/trees/04_agent_skirmisher.tres @@ -9,17 +9,17 @@ [ext_resource type="Script" path="res://demo/ai/tasks/back_away.gd" id="6_fkv0k"] [sub_resource type="BlackboardPlan" id="BlackboardPlan_46tbn"] -var/speed/name = "speed" +var/speed/name = &"speed" var/speed/type = 3 var/speed/value = 400.0 var/speed/hint = 1 var/speed/hint_string = "10,1000,10" -var/fast_speed/name = "fast_speed" +var/fast_speed/name = &"fast_speed" var/fast_speed/type = 3 var/fast_speed/value = 600.0 var/fast_speed/hint = 1 var/fast_speed/hint_string = "10,1000,10" -var/slow_speed/name = "slow_speed" +var/slow_speed/name = &"slow_speed" var/slow_speed/type = 3 var/slow_speed/value = 300.0 var/slow_speed/hint = 1 diff --git a/demo/demo/ai/trees/05_agent_ranged.tres b/demo/demo/ai/trees/05_agent_ranged.tres index 8333a7c..97bcc98 100644 --- a/demo/demo/ai/trees/05_agent_ranged.tres +++ b/demo/demo/ai/trees/05_agent_ranged.tres @@ -7,12 +7,12 @@ [ext_resource type="Script" path="res://demo/ai/tasks/face_target.gd" id="5_aexyq"] [sub_resource type="BlackboardPlan" id="BlackboardPlan_46tbn"] -var/speed/name = "speed" +var/speed/name = &"speed" var/speed/type = 3 var/speed/value = 400.0 var/speed/hint = 1 var/speed/hint_string = "10,1000,10" -var/run_speed/name = "run_speed" +var/run_speed/name = &"run_speed" var/run_speed/type = 3 var/run_speed/value = 600.0 var/run_speed/hint = 1 diff --git a/demo/demo/ai/trees/06_agent_melee_combo.tres b/demo/demo/ai/trees/06_agent_melee_combo.tres index c939ea4..a8312b3 100644 --- a/demo/demo/ai/trees/06_agent_melee_combo.tres +++ b/demo/demo/ai/trees/06_agent_melee_combo.tres @@ -7,12 +7,12 @@ [ext_resource type="Script" path="res://demo/ai/tasks/move_forward.gd" id="5_au5yc"] [sub_resource type="BlackboardPlan" id="BlackboardPlan_46tbn"] -var/speed/name = "speed" +var/speed/name = &"speed" var/speed/type = 3 var/speed/value = 400.0 var/speed/hint = 1 var/speed/hint_string = "10,1000,10" -var/charge_speed/name = "charge_speed" +var/charge_speed/name = &"charge_speed" var/charge_speed/type = 3 var/charge_speed/value = 1000.0 var/charge_speed/hint = 0 diff --git a/demo/demo/ai/trees/07_agent_melee_nuanced.tres b/demo/demo/ai/trees/07_agent_melee_nuanced.tres index ff7b80e..50dfc82 100644 --- a/demo/demo/ai/trees/07_agent_melee_nuanced.tres +++ b/demo/demo/ai/trees/07_agent_melee_nuanced.tres @@ -7,12 +7,12 @@ [ext_resource type="Script" path="res://demo/ai/tasks/pursue.gd" id="5_r1ou0"] [sub_resource type="BlackboardPlan" id="BlackboardPlan_46tbn"] -var/speed/name = "speed" +var/speed/name = &"speed" var/speed/type = 3 var/speed/value = 400.0 var/speed/hint = 1 var/speed/hint_string = "10,1000,10" -var/flank_speed/name = "flank_speed" +var/flank_speed/name = &"flank_speed" var/flank_speed/type = 3 var/flank_speed/value = 600.0 var/flank_speed/hint = 1 diff --git a/demo/demo/ai/trees/08_agent_demon.tres b/demo/demo/ai/trees/08_agent_demon.tres index 9825e5f..99a5597 100644 --- a/demo/demo/ai/trees/08_agent_demon.tres +++ b/demo/demo/ai/trees/08_agent_demon.tres @@ -8,7 +8,7 @@ [ext_resource type="Script" path="res://demo/ai/tasks/arrive_pos.gd" id="6_0pfsl"] [sub_resource type="BlackboardPlan" id="BlackboardPlan_8ay3j"] -var/speed/name = "speed" +var/speed/name = &"speed" var/speed/type = 3 var/speed/value = 400.0 var/speed/hint = 1 diff --git a/demo/demo/ai/trees/09_agent_summoner.tres b/demo/demo/ai/trees/09_agent_summoner.tres index 199a70d..39191e2 100644 --- a/demo/demo/ai/trees/09_agent_summoner.tres +++ b/demo/demo/ai/trees/09_agent_summoner.tres @@ -4,12 +4,12 @@ [ext_resource type="Script" path="res://demo/ai/tasks/arrive_pos.gd" id="2_pshl2"] [sub_resource type="BlackboardPlan" id="BlackboardPlan_58oq1"] -var/speed/name = "speed" +var/speed/name = &"speed" var/speed/type = 3 var/speed/value = 300.0 var/speed/hint = 1 var/speed/hint_string = "10,1000,10" -var/summon_cooldown/name = "summon_cooldown" +var/summon_cooldown/name = &"summon_cooldown" var/summon_cooldown/type = 1 var/summon_cooldown/value = false var/summon_cooldown/hint = 0 @@ -53,7 +53,7 @@ type = 1 [sub_resource type="BTCheckVar" id="BTCheckVar_hc3o3"] children = [SubResource("BTComment_ef6y0")] -variable = "summon_cooldown" +variable = &"summon_cooldown" value = SubResource("BBVariant_hgde2") [sub_resource type="BBNode" id="BBNode_q8bei"] @@ -77,7 +77,7 @@ position_var = "minion_pos" [sub_resource type="BBVariant" id="BBVariant_wfjwy"] resource_name = "$minion_pos" value_source = 1 -variable = "minion_pos" +variable = &"minion_pos" type = 5 [sub_resource type="BBNode" id="BBNode_v271m"] @@ -92,7 +92,7 @@ args = Array[BBVariant]([SubResource("BBVariant_wfjwy")]) [sub_resource type="BTCooldown" id="BTCooldown_25f70"] children = [SubResource("BTCallMethod_4ath5")] duration = 6.0 -cooldown_state_var = "summon_cooldown" +cooldown_state_var = &"summon_cooldown" [sub_resource type="BTWait" id="BTWait_tdhfn"] diff --git a/demo/demo/ai/tutorial_trees/tutorial_01_welcome.tres b/demo/demo/ai/tutorial_trees/tutorial_01_welcome.tres index 1e4a849..84f1d04 100644 --- a/demo/demo/ai/tutorial_trees/tutorial_01_welcome.tres +++ b/demo/demo/ai/tutorial_trees/tutorial_01_welcome.tres @@ -1,15 +1,15 @@ [gd_resource type="BehaviorTree" load_steps=5 format=3 uid="uid://b1mfh8yad7rmw"] [sub_resource type="BlackboardPlan" id="BlackboardPlan_ewfwq"] -var/speed/name = "speed" +var/speed/name = &"speed" var/speed/type = 3 var/speed/value = 400.0 var/speed/hint = 1 var/speed/hint_string = "10,1000,10" [sub_resource type="BBNode" id="BBNode_fq0jf"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_rsejo"] animation_player = SubResource("BBNode_fq0jf") diff --git a/demo/demo/ai/tutorial_trees/tutorial_02_introduction.tres b/demo/demo/ai/tutorial_trees/tutorial_02_introduction.tres index a8d5f40..985582b 100644 --- a/demo/demo/ai/tutorial_trees/tutorial_02_introduction.tres +++ b/demo/demo/ai/tutorial_trees/tutorial_02_introduction.tres @@ -1,20 +1,20 @@ [gd_resource type="BehaviorTree" load_steps=9 format=3 uid="uid://b1i0xo0o676va"] [sub_resource type="BlackboardPlan" id="BlackboardPlan_ewfwq"] -var/speed/name = "speed" +var/speed/name = &"speed" var/speed/type = 3 var/speed/value = 400.0 var/speed/hint = 1 var/speed/hint_string = "10,1000,10" -var/flank_speed/name = "flank_speed" +var/flank_speed/name = &"flank_speed" var/flank_speed/type = 3 var/flank_speed/value = 600.0 var/flank_speed/hint = 1 var/flank_speed/hint_string = "10,1000,10" [sub_resource type="BBNode" id="BBNode_wu06u"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_dubaq"] animation_player = SubResource("BBNode_wu06u") @@ -24,8 +24,8 @@ animation_name = &"idle" duration = 5.0 [sub_resource type="BBNode" id="BBNode_mgehh"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_0fqno"] animation_player = SubResource("BBNode_mgehh") diff --git a/demo/demo/ai/tutorial_trees/tutorial_03_types.tres b/demo/demo/ai/tutorial_trees/tutorial_03_types.tres index b25c02d..6450d0e 100644 --- a/demo/demo/ai/tutorial_trees/tutorial_03_types.tres +++ b/demo/demo/ai/tutorial_trees/tutorial_03_types.tres @@ -7,15 +7,15 @@ [ext_resource type="Script" path="res://demo/ai/tasks/face_target.gd" id="5_thvy5"] [sub_resource type="BlackboardPlan" id="BlackboardPlan_ewfwq"] -var/speed/name = "speed" +var/speed/name = &"speed" var/speed/type = 3 var/speed/value = 400.0 var/speed/hint = 1 var/speed/hint_string = "10,1000,10" [sub_resource type="BBNode" id="BBNode_20ku0"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_57u80"] animation_player = SubResource("BBNode_20ku0") @@ -56,8 +56,8 @@ script = ExtResource("5_thvy5") target_var = "target" [sub_resource type="BBNode" id="BBNode_ilr2h"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_mrsu3"] animation_player = SubResource("BBNode_ilr2h") @@ -67,8 +67,8 @@ animation_name = &"attack_1" children = [SubResource("BTAction_124bm"), SubResource("BTCondition_n25o8"), SubResource("BTAction_1hfgr"), SubResource("BTPlayAnimation_mrsu3")] [sub_resource type="BBNode" id="BBNode_fq0jf"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_rsejo"] animation_player = SubResource("BBNode_fq0jf") diff --git a/demo/demo/ai/tutorial_trees/tutorial_04_sequence.tres b/demo/demo/ai/tutorial_trees/tutorial_04_sequence.tres index 232a7a2..ea62214 100644 --- a/demo/demo/ai/tutorial_trees/tutorial_04_sequence.tres +++ b/demo/demo/ai/tutorial_trees/tutorial_04_sequence.tres @@ -4,15 +4,15 @@ [ext_resource type="Script" path="res://demo/ai/tasks/arrive_pos.gd" id="2_v5eou"] [sub_resource type="BlackboardPlan" id="BlackboardPlan_ewfwq"] -var/speed/name = "speed" +var/speed/name = &"speed" var/speed/type = 3 var/speed/value = 400.0 var/speed/hint = 1 var/speed/hint_string = "10,1000,10" [sub_resource type="BBNode" id="BBNode_fq0jf"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_rsejo"] animation_player = SubResource("BBNode_fq0jf") @@ -22,8 +22,8 @@ animation_name = &"idle" duration = 3.0 [sub_resource type="BBNode" id="BBNode_6d0yy"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_wsspf"] animation_player = SubResource("BBNode_6d0yy") diff --git a/demo/demo/ai/tutorial_trees/tutorial_05_selector.tres b/demo/demo/ai/tutorial_trees/tutorial_05_selector.tres index 25a6a1b..52c494a 100644 --- a/demo/demo/ai/tutorial_trees/tutorial_05_selector.tres +++ b/demo/demo/ai/tutorial_trees/tutorial_05_selector.tres @@ -7,7 +7,7 @@ [ext_resource type="Script" path="res://demo/ai/tasks/arrive_pos.gd" id="2_t62a0"] [sub_resource type="BlackboardPlan" id="BlackboardPlan_ewfwq"] -var/speed/name = "speed" +var/speed/name = &"speed" var/speed/type = 3 var/speed/value = 400.0 var/speed/hint = 1 @@ -20,8 +20,8 @@ distance_max = 200.0 target_var = "target" [sub_resource type="BBNode" id="BBNode_icf24"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_iiei3"] animation_player = SubResource("BBNode_icf24") @@ -41,8 +41,8 @@ tolerance = 50.0 avoid_var = "" [sub_resource type="BBNode" id="BBNode_ayt56"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_l1tdg"] animation_player = SubResource("BBNode_ayt56") @@ -61,8 +61,8 @@ distance_max = 10000.0 target_var = "target" [sub_resource type="BBNode" id="BBNode_6d0yy"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_wsspf"] animation_player = SubResource("BBNode_6d0yy") @@ -75,8 +75,8 @@ speed_var = "speed" approach_distance = 100.0 [sub_resource type="BBNode" id="BBNode_aw5jj"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_3aihc"] animation_player = SubResource("BBNode_aw5jj") diff --git a/demo/demo/ai/tutorial_trees/tutorial_06_decorators.tres b/demo/demo/ai/tutorial_trees/tutorial_06_decorators.tres index bac3d83..1b4f820 100644 --- a/demo/demo/ai/tutorial_trees/tutorial_06_decorators.tres +++ b/demo/demo/ai/tutorial_trees/tutorial_06_decorators.tres @@ -8,7 +8,7 @@ [ext_resource type="Script" path="res://demo/ai/tasks/pursue.gd" id="6_rpn40"] [sub_resource type="BlackboardPlan" id="BlackboardPlan_ewfwq"] -var/speed/name = "speed" +var/speed/name = &"speed" var/speed/type = 3 var/speed/value = 400.0 var/speed/hint = 1 @@ -33,8 +33,8 @@ script = ExtResource("3_orhnl") target_var = "target" [sub_resource type="BBNode" id="BBNode_6d0yy"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_wsspf"] await_completion = 5.0 @@ -45,8 +45,8 @@ animation_name = &"attack_1" children = [SubResource("BTCondition_m15aa"), SubResource("BTAction_oc76s"), SubResource("BTPlayAnimation_wsspf")] [sub_resource type="BTCooldown" id="BTCooldown_3tvjt"] -duration = 5.0 children = [SubResource("BTSequence_e0f8v")] +duration = 5.0 [sub_resource type="BTCondition" id="BTCondition_x0uu7"] script = ExtResource("2_08b67") @@ -55,8 +55,8 @@ distance_max = 200.0 target_var = "target" [sub_resource type="BBNode" id="BBNode_icf24"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_iiei3"] animation_player = SubResource("BBNode_icf24") @@ -76,8 +76,8 @@ tolerance = 50.0 avoid_var = "" [sub_resource type="BBNode" id="BBNode_ayt56"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_l1tdg"] animation_player = SubResource("BBNode_ayt56") @@ -96,8 +96,8 @@ distance_max = 10000.0 target_var = "target" [sub_resource type="BBNode" id="BBNode_rpwld"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_dug2k"] animation_player = SubResource("BBNode_rpwld") @@ -110,8 +110,8 @@ speed_var = "speed" approach_distance = 100.0 [sub_resource type="BBNode" id="BBNode_aw5jj"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_3aihc"] animation_player = SubResource("BBNode_aw5jj") diff --git a/demo/demo/ai/tutorial_trees/tutorial_07_more_decorators.tres b/demo/demo/ai/tutorial_trees/tutorial_07_more_decorators.tres index d186a82..abd8ad9 100644 --- a/demo/demo/ai/tutorial_trees/tutorial_07_more_decorators.tres +++ b/demo/demo/ai/tutorial_trees/tutorial_07_more_decorators.tres @@ -7,7 +7,7 @@ [ext_resource type="Script" path="res://demo/ai/tasks/pursue.gd" id="6_1yikm"] [sub_resource type="BlackboardPlan" id="BlackboardPlan_ewfwq"] -var/speed/name = "speed" +var/speed/name = &"speed" var/speed/type = 3 var/speed/value = 400.0 var/speed/hint = 1 @@ -32,8 +32,8 @@ script = ExtResource("3_86p0r") target_var = "target" [sub_resource type="BBNode" id="BBNode_6d0yy"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_wsspf"] await_completion = 5.0 @@ -41,8 +41,8 @@ animation_player = SubResource("BBNode_6d0yy") animation_name = &"attack_1" [sub_resource type="BBNode" id="BBNode_w45kn"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_d2lad"] await_completion = 5.0 @@ -53,8 +53,8 @@ animation_name = &"attack_2" children = [SubResource("BTCondition_m15aa"), SubResource("BTAction_oc76s"), SubResource("BTPlayAnimation_wsspf"), SubResource("BTPlayAnimation_d2lad")] [sub_resource type="BTCooldown" id="BTCooldown_3tvjt"] -duration = 5.0 children = [SubResource("BTSequence_e0f8v")] +duration = 5.0 [sub_resource type="BTCondition" id="BTCondition_x0uu7"] script = ExtResource("2_mj1cj") @@ -63,8 +63,8 @@ distance_max = 200.0 target_var = "target" [sub_resource type="BBNode" id="BBNode_wksgd"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_umlwj"] animation_player = SubResource("BBNode_wksgd") @@ -76,15 +76,15 @@ speed_var = "speed" max_angle_deviation = 0.7 [sub_resource type="BTTimeLimit" id="BTTimeLimit_6eii7"] -time_limit = 2.0 children = [SubResource("BTAction_6q0k4")] +time_limit = 2.0 [sub_resource type="BTAlwaysSucceed" id="BTAlwaysSucceed_ieord"] children = [SubResource("BTTimeLimit_6eii7")] [sub_resource type="BBNode" id="BBNode_ayt56"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_l1tdg"] animation_player = SubResource("BBNode_ayt56") @@ -103,8 +103,8 @@ distance_max = 10000.0 target_var = "target" [sub_resource type="BBNode" id="BBNode_rpwld"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_dug2k"] animation_player = SubResource("BBNode_rpwld") @@ -117,8 +117,8 @@ speed_var = "speed" approach_distance = 100.0 [sub_resource type="BBNode" id="BBNode_aw5jj"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_3aihc"] animation_player = SubResource("BBNode_aw5jj") diff --git a/demo/demo/ai/tutorial_trees/tutorial_08_final_touch.tres b/demo/demo/ai/tutorial_trees/tutorial_08_final_touch.tres index 07d251c..23b0fad 100644 --- a/demo/demo/ai/tutorial_trees/tutorial_08_final_touch.tres +++ b/demo/demo/ai/tutorial_trees/tutorial_08_final_touch.tres @@ -9,7 +9,7 @@ [ext_resource type="Script" path="res://demo/ai/tasks/pursue.gd" id="7_ekws5"] [sub_resource type="BlackboardPlan" id="BlackboardPlan_ewfwq"] -var/speed/name = "speed" +var/speed/name = &"speed" var/speed/type = 3 var/speed/value = 400.0 var/speed/hint = 1 @@ -34,8 +34,8 @@ script = ExtResource("4_128ei") target_var = "target" [sub_resource type="BBNode" id="BBNode_6d0yy"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_wsspf"] await_completion = 5.0 @@ -43,8 +43,8 @@ animation_player = SubResource("BBNode_6d0yy") animation_name = &"attack_1" [sub_resource type="BBNode" id="BBNode_w45kn"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_d2lad"] await_completion = 5.0 @@ -55,8 +55,8 @@ animation_name = &"attack_2" children = [SubResource("BTCondition_m15aa"), SubResource("BTAction_oc76s"), SubResource("BTPlayAnimation_wsspf"), SubResource("BTPlayAnimation_d2lad")] [sub_resource type="BTCooldown" id="BTCooldown_3tvjt"] -duration = 5.0 children = [SubResource("BTSequence_e0f8v")] +duration = 5.0 [sub_resource type="BTCondition" id="BTCondition_x0uu7"] script = ExtResource("5_er18b") @@ -65,8 +65,8 @@ distance_max = 200.0 target_var = "target" [sub_resource type="BBNode" id="BBNode_wksgd"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_umlwj"] animation_player = SubResource("BBNode_wksgd") @@ -78,15 +78,15 @@ speed_var = "speed" max_angle_deviation = 0.7 [sub_resource type="BTTimeLimit" id="BTTimeLimit_6eii7"] -time_limit = 2.0 children = [SubResource("BTAction_6q0k4")] +time_limit = 2.0 [sub_resource type="BTAlwaysSucceed" id="BTAlwaysSucceed_ieord"] children = [SubResource("BTTimeLimit_6eii7")] [sub_resource type="BBNode" id="BBNode_ayt56"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_l1tdg"] animation_player = SubResource("BBNode_ayt56") @@ -107,8 +107,8 @@ range_max = 500 position_var = "pos" [sub_resource type="BBNode" id="BBNode_icf24"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_iiei3"] animation_player = SubResource("BBNode_icf24") @@ -126,8 +126,8 @@ script = ExtResource("4_128ei") target_var = "target" [sub_resource type="BBNode" id="BBNode_h4k80"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_40yja"] animation_player = SubResource("BBNode_h4k80") @@ -136,8 +136,8 @@ animation_name = &"throw_prepare" [sub_resource type="BTWait" id="BTWait_2dc1v"] [sub_resource type="BBNode" id="BBNode_slipn"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_qnpjq"] await_completion = 5.0 @@ -145,8 +145,8 @@ animation_player = SubResource("BBNode_slipn") animation_name = &"throw" [sub_resource type="BBNode" id="BBNode_qaqnn"] -saved_value = NodePath(".") resource_name = "." +saved_value = NodePath(".") [sub_resource type="BTCallMethod" id="BTCallMethod_yd0fn"] node = SubResource("BBNode_qaqnn") @@ -156,8 +156,8 @@ method = &"throw_ninja_star" children = [SubResource("BTAction_n0rxm"), SubResource("BTPlayAnimation_iiei3"), SubResource("BTAction_g2up4"), SubResource("BTAction_d5lkr"), SubResource("BTPlayAnimation_40yja"), SubResource("BTWait_2dc1v"), SubResource("BTPlayAnimation_qnpjq"), SubResource("BTCallMethod_yd0fn")] [sub_resource type="BTProbability" id="BTProbability_omklt"] -run_chance = 0.25 children = [SubResource("BTSequence_ws7nq")] +run_chance = 0.25 [sub_resource type="BTCondition" id="BTCondition_d6aub"] script = ExtResource("5_er18b") @@ -166,8 +166,8 @@ distance_max = 10000.0 target_var = "target" [sub_resource type="BBNode" id="BBNode_rpwld"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_dug2k"] animation_player = SubResource("BBNode_rpwld") @@ -180,8 +180,8 @@ speed_var = "speed" approach_distance = 100.0 [sub_resource type="BBNode" id="BBNode_aw5jj"] -saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" +saved_value = NodePath("AnimationPlayer") [sub_resource type="BTPlayAnimation" id="BTPlayAnimation_3aihc"] animation_player = SubResource("BBNode_aw5jj") diff --git a/demo/demo/scenes/showcase.tscn b/demo/demo/scenes/showcase.tscn index 5e7946a..0f22e83 100644 --- a/demo/demo/scenes/showcase.tscn +++ b/demo/demo/scenes/showcase.tscn @@ -257,8 +257,8 @@ anchor_right = 1.0 anchor_bottom = 1.0 offset_left = 4.0 offset_top = 4.0 -offset_right = -4.0 -offset_bottom = -4.0 +offset_right = 1020.0 +offset_bottom = 704.0 grow_horizontal = 2 grow_vertical = 2 gutters_draw_line_numbers = true