diff --git a/demo/demo/agents/agent_imp.tscn b/demo/demo/agents/agent_imp.tscn index db587fd..bbf230e 100644 --- a/demo/demo/agents/agent_imp.tscn +++ b/demo/demo/agents/agent_imp.tscn @@ -2,7 +2,7 @@ [ext_resource type="PackedScene" uid="uid://ooigbfhfy4wa" path="res://demo/agents/agent_base.tscn" id="1_c1bsr"] [ext_resource type="Texture2D" uid="uid://h70okn6hmxum" path="res://demo/assets/agent_imp.png" id="2_vnje4"] -[ext_resource type="BehaviorTree" uid="uid://c2bxoo68ywb27" path="res://demo/ai/trees/enemy_melee_imp.tres" id="3_u821b"] +[ext_resource type="BehaviorTree" uid="uid://c2bxoo68ywb27" path="res://demo/ai/trees/02_agent_imp.tres" id="3_xjn4q"] [sub_resource type="BlackboardPlan" id="BlackboardPlan_aog23"] var/speed/name = "speed" @@ -35,5 +35,5 @@ texture = ExtResource("2_vnje4") max_health = 5.0 [node name="BTPlayer" type="BTPlayer" parent="." index="5"] -behavior_tree = ExtResource("3_u821b") +behavior_tree = ExtResource("3_xjn4q") blackboard_plan = SubResource("BlackboardPlan_aog23") diff --git a/demo/demo/ai/trees/enemy_melee_imp.tres b/demo/demo/ai/trees/02_agent_imp.tres similarity index 83% rename from demo/demo/ai/trees/enemy_melee_imp.tres rename to demo/demo/ai/trees/02_agent_imp.tres index 5c3d44d..22caf0e 100644 --- a/demo/demo/ai/trees/enemy_melee_imp.tres +++ b/demo/demo/ai/trees/02_agent_imp.tres @@ -1,10 +1,10 @@ -[gd_resource type="BehaviorTree" load_steps=32 format=3 uid="uid://c2bxoo68ywb27"] +[gd_resource type="BehaviorTree" load_steps=30 format=3 uid="uid://c2bxoo68ywb27"] -[ext_resource type="Script" path="res://demo/ai/tasks/get_first_in_group.gd" id="1_sqcak"] -[ext_resource type="Script" path="res://demo/ai/tasks/pursue.gd" id="2_b40lk"] -[ext_resource type="Script" path="res://demo/ai/tasks/face_target.gd" id="3_j237c"] -[ext_resource type="Script" path="res://demo/ai/tasks/select_random_nearby_pos.gd" id="4_fqn6n"] -[ext_resource type="Script" path="res://demo/ai/tasks/arrive_pos.gd" id="5_wlc74"] +[ext_resource type="Script" path="res://demo/ai/tasks/select_random_nearby_pos.gd" id="1_qgdmn"] +[ext_resource type="Script" path="res://demo/ai/tasks/arrive_pos.gd" id="2_kcs76"] +[ext_resource type="Script" path="res://demo/ai/tasks/get_first_in_group.gd" id="3_cy2w4"] +[ext_resource type="Script" path="res://demo/ai/tasks/pursue.gd" id="4_lorkr"] +[ext_resource type="Script" path="res://demo/ai/tasks/face_target.gd" id="5_1vcyu"] [sub_resource type="BlackboardPlan" id="BlackboardPlan_46tbn"] var/speed/name = "speed" @@ -13,11 +13,6 @@ var/speed/value = 400.0 var/speed/hint = 1 var/speed/hint_string = "10,1000,10" -[sub_resource type="BTAction" id="BTAction_5j8nr"] -script = ExtResource("1_sqcak") -group = &"player" -output_var = "target" - [sub_resource type="BBNode" id="BBNode_3y70b"] saved_value = NodePath("AnimationPlayer") resource_name = "AnimationPlayer" @@ -27,25 +22,21 @@ animation_player = SubResource("BBNode_3y70b") animation_name = &"walk" blend = 0.1 -[sub_resource type="BTAction" id="BTAction_wjm6d"] -script = ExtResource("3_j237c") -target_var = "target" - [sub_resource type="BTAction" id="BTAction_chmiy"] -script = ExtResource("4_fqn6n") +script = ExtResource("1_qgdmn") range_min = 200.0 range_max = 500.0 position_var = "pos" [sub_resource type="BTAction" id="BTAction_5kivl"] -script = ExtResource("5_wlc74") +script = ExtResource("2_kcs76") target_position_var = "pos" speed_var = "speed" tolerance = 50.0 [sub_resource type="BTSequence" id="BTSequence_k184c"] custom_name = "Chaotic Walk" -children = [SubResource("BTAction_5j8nr"), SubResource("BTPlayAnimation_klk26"), SubResource("BTAction_wjm6d"), SubResource("BTAction_chmiy"), SubResource("BTAction_5kivl")] +children = [SubResource("BTPlayAnimation_klk26"), SubResource("BTAction_chmiy"), SubResource("BTAction_5kivl")] [sub_resource type="BTProbability" id="BTProbability_ifsry"] run_chance = 0.6 @@ -78,12 +69,12 @@ animation_name = &"walk" blend = 0.1 [sub_resource type="BTAction" id="BTAction_ulbrf"] -script = ExtResource("1_sqcak") +script = ExtResource("3_cy2w4") group = &"player" output_var = "target" [sub_resource type="BTAction" id="BTAction_a4jqi"] -script = ExtResource("2_b40lk") +script = ExtResource("4_lorkr") target_var = "target" speed_var = "speed" approach_distance = 100.0 @@ -97,7 +88,7 @@ custom_name = "Pursue player" children = [SubResource("BTPlayAnimation_olf37"), SubResource("BTAction_ulbrf"), SubResource("BTTimeLimit_xek5v")] [sub_resource type="BTAction" id="BTAction_kidxn"] -script = ExtResource("3_j237c") +script = ExtResource("5_1vcyu") target_var = "target" [sub_resource type="BTWait" id="BTWait_tadkc"] diff --git a/demo/demo/assets/behavior_tree_view.theme b/demo/demo/assets/behavior_tree_view.theme new file mode 100644 index 0000000..d82b2eb Binary files /dev/null and b/demo/demo/assets/behavior_tree_view.theme differ diff --git a/demo/demo/assets/fonts/junction_bold.otf b/demo/demo/assets/fonts/junction_bold.otf new file mode 100644 index 0000000..45a6697 Binary files /dev/null and b/demo/demo/assets/fonts/junction_bold.otf differ diff --git a/demo/demo/assets/fonts/junction_bold.otf.import b/demo/demo/assets/fonts/junction_bold.otf.import new file mode 100644 index 0000000..b3a9e68 --- /dev/null +++ b/demo/demo/assets/fonts/junction_bold.otf.import @@ -0,0 +1,33 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://n231m6uqsq6x" +path="res://.godot/imported/junction_bold.otf-4db2200a8b1a6423bafe2a4e7c7abbde.fontdata" + +[deps] + +source_file="res://demo/assets/fonts/junction_bold.otf" +dest_files=["res://.godot/imported/junction_bold.otf-4db2200a8b1a6423bafe2a4e7c7abbde.fontdata"] + +[params] + +Rendering=null +antialiasing=1 +generate_mipmaps=false +multichannel_signed_distance_field=false +msdf_pixel_range=8 +msdf_size=48 +allow_system_fallback=true +force_autohinter=false +hinting=1 +subpixel_positioning=1 +oversampling=0.0 +Fallbacks=null +fallbacks=[] +Compress=null +compress=true +preload=[] +language_support={} +script_support={} +opentype_features={} diff --git a/demo/demo/assets/fonts/knewave_regular.ttf b/demo/demo/assets/fonts/knewave_regular.ttf new file mode 100644 index 0000000..a98f750 Binary files /dev/null and b/demo/demo/assets/fonts/knewave_regular.ttf differ diff --git a/demo/demo/assets/fonts/knewave_regular.ttf.import b/demo/demo/assets/fonts/knewave_regular.ttf.import new file mode 100644 index 0000000..32d5a2e --- /dev/null +++ b/demo/demo/assets/fonts/knewave_regular.ttf.import @@ -0,0 +1,33 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://d25vkmce7mhlt" +path="res://.godot/imported/knewave_regular.ttf-955953b059f713782c7b07e66ab341ec.fontdata" + +[deps] + +source_file="res://demo/assets/fonts/knewave_regular.ttf" +dest_files=["res://.godot/imported/knewave_regular.ttf-955953b059f713782c7b07e66ab341ec.fontdata"] + +[params] + +Rendering=null +antialiasing=1 +generate_mipmaps=false +multichannel_signed_distance_field=false +msdf_pixel_range=8 +msdf_size=48 +allow_system_fallback=true +force_autohinter=false +hinting=1 +subpixel_positioning=1 +oversampling=0.0 +Fallbacks=null +fallbacks=[] +Compress=null +compress=true +preload=[] +language_support={} +script_support={} +opentype_features={} diff --git a/demo/demo/assets/logo.png b/demo/demo/assets/logo.png new file mode 100644 index 0000000..0533077 Binary files /dev/null and b/demo/demo/assets/logo.png differ diff --git a/demo/demo/assets/logo.png.import b/demo/demo/assets/logo.png.import new file mode 100644 index 0000000..e0d85bf --- /dev/null +++ b/demo/demo/assets/logo.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://tyu0ua1ju38l" +path="res://.godot/imported/logo.png-627f053fd17248d48d9d002bdb02afc3.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://demo/assets/logo.png" +dest_files=["res://.godot/imported/logo.png-627f053fd17248d48d9d002bdb02afc3.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/demo/demo/props/dummy.gd b/demo/demo/props/dummy.gd index 9716223..2047fd5 100644 --- a/demo/demo/props/dummy.gd +++ b/demo/demo/props/dummy.gd @@ -9,3 +9,5 @@ func _on_health_damaged(_amount: float, _knockback: Vector2) -> void: animation_player.clear_queue() animation_player.play(&"hurt", 0.1) +func get_facing() -> float: + return signf(root.scale.x) diff --git a/demo/demo/scenes/01_imp_demo.tscn b/demo/demo/scenes/01_imp_demo.tscn deleted file mode 100644 index f129e69..0000000 --- a/demo/demo/scenes/01_imp_demo.tscn +++ /dev/null @@ -1,25 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://b3ae14mc2ty3y"] - -[ext_resource type="PackedScene" uid="uid://bsig1usigbbuy" path="res://demo/scenes/arena.tscn" id="1_cyyay"] -[ext_resource type="PackedScene" uid="uid://c5fhe3tulhlco" path="res://demo/props/dummy.tscn" id="2_gp6iv"] -[ext_resource type="PackedScene" uid="uid://730bthc0ywhd" path="res://demo/agents/agent_imp.tscn" id="3_p2jr5"] - -[node name="01 - Imp Demo" type="Node2D"] -y_sort_enabled = true - -[node name="Arena" parent="." instance=ExtResource("1_cyyay")] - -[node name="Dummy" parent="." instance=ExtResource("2_gp6iv")] -position = Vector2(1106, 423) - -[node name="AgentImp" parent="." instance=ExtResource("3_p2jr5")] -position = Vector2(1623, 426) - -[node name="Camera2D" type="Camera2D" parent="AgentImp"] -zoom = Vector2(0.88, 0.88) -process_callback = 0 -position_smoothing_enabled = true -drag_horizontal_enabled = true -drag_vertical_enabled = true -drag_top_margin = 0.1 -drag_bottom_margin = 0.1 diff --git a/demo/demo/scenes/agent_showcase.gd b/demo/demo/scenes/agent_showcase.gd new file mode 100644 index 0000000..54bf3ff --- /dev/null +++ b/demo/demo/scenes/agent_showcase.gd @@ -0,0 +1,31 @@ +extends Node2D + +@onready var behavior_tree_view: BehaviorTreeView = %BehaviorTreeView +@onready var camera: Camera2D = $Camera2D +@onready var resource_name: Label = $CanvasLayer/ResourceName + +var bt_player: BTPlayer + +func _ready() -> void: + var agent: CharacterBody2D + for child in get_children(): + if child is CharacterBody2D: + bt_player = child.find_child("BTPlayer") + if bt_player != null: + agent = child + resource_name.text = bt_player.behavior_tree.resource_path.get_file() + break + _attach_camera(agent) + + +func _physics_process(_delta: float) -> void: + var inst: BTTask = bt_player.get_tree_instance() + var bt_data: BehaviorTreeData = BehaviorTreeData.create_from_tree_instance(inst) + behavior_tree_view.update_tree(bt_data) + + +func _attach_camera(agent: CharacterBody2D) -> void: + await get_tree().process_frame + camera.get_parent().remove_child(camera) + agent.add_child(camera) + camera.position = Vector2(400.0, 0.0) diff --git a/demo/demo/scenes/agent_showcase.tscn b/demo/demo/scenes/agent_showcase.tscn new file mode 100644 index 0000000..9c7959a --- /dev/null +++ b/demo/demo/scenes/agent_showcase.tscn @@ -0,0 +1,108 @@ +[gd_scene load_steps=11 format=3 uid="uid://b3ae14mc2ty3y"] + +[ext_resource type="Script" path="res://demo/scenes/agent_showcase.gd" id="1_frr2n"] +[ext_resource type="Theme" uid="uid://boqtjf88xcpu4" path="res://demo/assets/behavior_tree_view.theme" id="2_hb4lh"] +[ext_resource type="Texture2D" uid="uid://tyu0ua1ju38l" path="res://demo/assets/logo.png" id="3_v6wtt"] +[ext_resource type="FontFile" uid="uid://d25vkmce7mhlt" path="res://demo/assets/fonts/knewave_regular.ttf" id="4_tju7a"] +[ext_resource type="FontFile" uid="uid://n231m6uqsq6x" path="res://demo/assets/fonts/junction_bold.otf" id="5_0fprc"] +[ext_resource type="PackedScene" uid="uid://bsig1usigbbuy" path="res://demo/scenes/arena.tscn" id="6_6awy2"] +[ext_resource type="PackedScene" uid="uid://c5fhe3tulhlco" path="res://demo/props/dummy.tscn" id="7_ao7an"] +[ext_resource type="PackedScene" uid="uid://ci3x5esepbu5v" path="res://demo/agents/agent_ranged.tscn" id="8_bfg8u"] + +[sub_resource type="LabelSettings" id="LabelSettings_la4ui"] +font = ExtResource("4_tju7a") +font_size = 36 +font_color = Color(1, 1, 0.239216, 1) +outline_size = 20 +outline_color = Color(0.211521, 0.23888, 0.290166, 1) + +[sub_resource type="LabelSettings" id="LabelSettings_3uhve"] +font = ExtResource("5_0fprc") +font_size = 38 +outline_size = 20 +outline_color = Color(0.0784314, 0.0941176, 0.117647, 1) + +[node name="AgentShowcase" type="Node2D"] +y_sort_enabled = true +script = ExtResource("1_frr2n") +metadata/_edit_horizontal_guides_ = [1019.0] + +[node name="CanvasLayer" type="CanvasLayer" parent="."] + +[node name="BehaviorTreeView" type="BehaviorTreeView" parent="CanvasLayer"] +unique_name_in_owner = true +custom_minimum_size = Vector2(600, 0) +offset_left = 1320.0 +offset_right = 1920.0 +offset_bottom = 1080.0 +grow_horizontal = 0 +grow_vertical = 2 +theme = ExtResource("2_hb4lh") + +[node name="Logo" type="TextureRect" parent="CanvasLayer"] +anchors_preset = 3 +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -1899.0 +offset_top = -130.0 +offset_right = -1643.0 +offset_bottom = -45.0 +grow_horizontal = 0 +grow_vertical = 0 +texture = ExtResource("3_v6wtt") + +[node name="Demo project" type="Label" parent="CanvasLayer/Logo"] +layout_mode = 1 +anchors_preset = 3 +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -316.0 +offset_top = -72.0 +offset_right = 13.0 +offset_bottom = 74.0 +grow_horizontal = 0 +grow_vertical = 0 +text = "demo project" +label_settings = SubResource("LabelSettings_la4ui") +horizontal_alignment = 2 +vertical_alignment = 1 + +[node name="ResourceName" type="Label" parent="CanvasLayer"] +anchors_preset = 3 +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -230.0 +offset_top = -146.0 +offset_right = -29.0 +grow_horizontal = 0 +grow_vertical = 0 +text = "o2_agent_imp.tres" +label_settings = SubResource("LabelSettings_3uhve") +horizontal_alignment = 2 +vertical_alignment = 1 + +[node name="Camera2D" type="Camera2D" parent="."] +position = Vector2(400, 0) +zoom = Vector2(0.88, 0.88) +process_callback = 0 +position_smoothing_enabled = true +drag_horizontal_enabled = true +drag_vertical_enabled = true +drag_left_margin = 0.1 +drag_top_margin = 0.1 +drag_right_margin = 0.0 +drag_bottom_margin = 0.1 + +[node name="Arena" parent="." instance=ExtResource("6_6awy2")] +metadata/_edit_lock_ = true + +[node name="Dummy" parent="." instance=ExtResource("7_ao7an")] +position = Vector2(1106, 423) + +[node name="AgentRanged" parent="." instance=ExtResource("8_bfg8u")]