From e7a9860a54f4f2427778e59713895769e58442e3 Mon Sep 17 00:00:00 2001 From: Rendo Date: Mon, 7 Jul 2025 23:14:32 +0500 Subject: [PATCH] Plants animation now supports timescale --- resources/animations/plants/sunflower.res | Bin 821 -> 790 bytes scenes/entities/plants/aloe.tscn | 22 +++++++++++++----- scenes/entities/plants/garlic.tscn | 18 ++++++++++---- scenes/entities/plants/peashooter.tscn | 17 +++++++++++--- scenes/entities/plants/potato_mine.tscn | 22 +++++++++++++----- scenes/entities/plants/snowpea.tscn | 14 +++++++++-- scenes/entities/plants/spikeweed.tscn | 18 ++++++++++---- scenes/entities/plants/sunflower.tscn | 21 ++++++++++++----- scenes/entities/plants/threepeater.tscn | 14 +++++++++-- scenes/entities/plants/wallnut.tscn | 19 +++++++++++---- scenes/templates/plant_template.tscn | 1 - scripts/components/Entity.cs | 4 +++- .../plants/behaviours/AloeBehaviour.cs | 4 ++-- .../plants/behaviours/HpBasedBehaviour.cs | 2 +- .../plants/behaviours/PeashooterBehaviour.cs | 2 +- .../plants/behaviours/PotatomineBehaviour.cs | 4 ++-- .../plants/behaviours/SpikeweedBehaviour.cs | 8 +++---- .../plants/behaviours/SunflowerBehaviour.cs | 11 ++------- 18 files changed, 141 insertions(+), 60 deletions(-) diff --git a/resources/animations/plants/sunflower.res b/resources/animations/plants/sunflower.res index 1f15a380fd39ade72d35cb6bda4043b479ec4c7e..107ee2934a324a3ad1ec3ff02fe7422c6bf8686c 100644 GIT binary patch literal 790 zcmV+x1L^!yQ$s@n000005C8zO2mk>70ssIgwJ-f(vInIX07hM8K`@Pz4iyI&3~?}I zL!}q+9WEk~+Qeil+2!1OlLlM# z!#7M2Mxf;!$<}?=G)>bqO_C%@k|fm$`=WHjp}8$8@EH|MJ|>)y2Ag9*7%ccukN`nS zZwQ6Oa`8C8>EPJ-lc36(flUU6M!-cTlj&?L)JEkQQLW0K;aIrtn;Pa~xqO^jP%1QT zYpAO7P@N3~^}l4>R!TaX2#{0GVD&gP-EAXdfKA&a$3(13qfzrgAwKWiWDS z60=u@@6i2`VaR}IP5v{-7+Tz3a2H=+(fZeSt3{xprgTs9!psNB#ixMu_^Q z<{c0{{RhwJ-f(BM6-s0EQlELm-Vd9SBk(AOL_^ z1W6*H%=OzW z->qxt|K&e}Z#e&6ixMb;Z+T1d3@7AbQzV<)GS<)`6lww?TQ6_W$EhbOa zY({U!MU8S9YwgkhHJNk#7w~_|ID1^o5aIh)CN2yc!O0EtpTjM8gJu%tPNrv}tN9R=pjK>ATz@KF(WTS1iY{C^uj5(CJImN}x0r zJ7^$kj)EgO8%Et9?}=k=%1lbPpomGSZY2Jw<13U~%7!u4jLQD0*_2;!1=>qzMZYZT zyIbO^o4}NgbeLQMyscM$?Jo3IZi!S7HthkTkr8rA~XR7%SYrx9s#cjs8~KKUgHFU{g%4nfn%q#d;L1g zLKq5g=n`BE5WZSI*i*eQO6|!Z`c|ORtw@DL*Zl|oU%Md%e2Ry^xp5f-Qd2`i)kc2A diff --git a/scenes/entities/plants/aloe.tscn b/scenes/entities/plants/aloe.tscn index 00dfc9e..9047d01 100644 --- a/scenes/entities/plants/aloe.tscn +++ b/scenes/entities/plants/aloe.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=18 format=3 uid="uid://bw1w8jp0yeypy"] +[gd_scene load_steps=20 format=3 uid="uid://bw1w8jp0yeypy"] [ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/templates/plant_template.tscn" id="1_n25yi"] [ext_resource type="Texture2D" uid="uid://b6tyoa5htapir" path="res://assets/sprites/atlases/plants/aloe.png" id="2_iup5p"] @@ -22,7 +22,7 @@ tracks/0/keys = { tracks/1/type = "value" tracks/1/imported = false tracks/1/enabled = true -tracks/1/path = NodePath("AnimationTree:parameters/conditions/heal") +tracks/1/path = NodePath("AnimationTree:parameters/Tree/conditions/heal") tracks/1/interp = 1 tracks/1/loop_wrap = true tracks/1/keys = { @@ -37,6 +37,8 @@ _data = { &"RESET": SubResource("Animation_vknky") } +[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_qtb3p"] + [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_c25ew"] animation = &"aloe/heal" @@ -80,12 +82,19 @@ states/aloe_recharge/position = Vector2(530, 171) transitions = ["Start", "aloe_idle", SubResource("AnimationNodeStateMachineTransition_gi6e0"), "aloe_heal", "aloe_idle_used", SubResource("AnimationNodeStateMachineTransition_l1t7h"), "aloe_recharge", "aloe_idle", SubResource("AnimationNodeStateMachineTransition_cut4s"), "aloe_idle", "aloe_heal", SubResource("AnimationNodeStateMachineTransition_um4ov"), "aloe_idle_used", "aloe_recharge", SubResource("AnimationNodeStateMachineTransition_4kdc0")] graph_offset = Vector2(-78.082, -71.7578) +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_gfy6j"] +graph_offset = Vector2(-383, 84) +nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_qtb3p") +nodes/TimeScale/position = Vector2(120, 120) +nodes/Tree/node = SubResource("AnimationNodeStateMachine_bldox") +nodes/Tree/position = Vector2(-140, 160) +node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"] + [sub_resource type="RectangleShape2D" id="RectangleShape2D_oe0dc"] size = Vector2(22, 32) [node name="Aloe" instance=ExtResource("1_n25yi")] MaxHP = 30.0 -_effectImmunities = Array[Resource]([]) [node name="Sprite2D" parent="." index="0"] position = Vector2(9, -14) @@ -100,9 +109,10 @@ libraries = { } [node name="AnimationTree" parent="." index="2"] -tree_root = SubResource("AnimationNodeStateMachine_bldox") -parameters/conditions/charged = false -parameters/conditions/heal = false +tree_root = SubResource("AnimationNodeBlendTree_gfy6j") +parameters/TimeScale/scale = 1.0 +parameters/Tree/conditions/charged = false +parameters/Tree/conditions/heal = false [node name="Behaviour" type="Node" parent="." index="3"] script = ExtResource("4_55asm") diff --git a/scenes/entities/plants/garlic.tscn b/scenes/entities/plants/garlic.tscn index bd855b0..46bea8a 100644 --- a/scenes/entities/plants/garlic.tscn +++ b/scenes/entities/plants/garlic.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=14 format=3 uid="uid://qq0cw8xtcoj3"] +[gd_scene load_steps=16 format=3 uid="uid://qq0cw8xtcoj3"] [ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/templates/plant_template.tscn" id="1_5i0e6"] [ext_resource type="Texture2D" uid="uid://dff73m8ahamaa" path="res://assets/sprites/atlases/plants/garlic.png" id="2_w2jbi"] @@ -27,6 +27,8 @@ _data = { &"RESET": SubResource("Animation_k0cex") } +[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_2d3xk"] + [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_mdv0r"] animation = &"garlic/full_hp" @@ -46,12 +48,19 @@ blend_point_2/pos = 0.3 min_space = 0.0 blend_mode = 1 +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_2o7sr"] +graph_offset = Vector2(-397, 76) +nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_2d3xk") +nodes/TimeScale/position = Vector2(100, 160) +nodes/Tree/node = SubResource("AnimationNodeBlendSpace1D_8mvpm") +nodes/Tree/position = Vector2(-160, 200) +node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"] + [sub_resource type="RectangleShape2D" id="RectangleShape2D_thlvs"] size = Vector2(32, 29) [node name="Garlic" instance=ExtResource("1_5i0e6")] MaxHP = 200.0 -_effectImmunities = Array[Resource]([]) [node name="Sprite2D" parent="." index="0"] texture = ExtResource("2_w2jbi") @@ -65,8 +74,9 @@ libraries = { } [node name="AnimationTree" parent="." index="2"] -tree_root = SubResource("AnimationNodeBlendSpace1D_8mvpm") -parameters/blend_position = 1.0 +tree_root = SubResource("AnimationNodeBlendTree_2o7sr") +parameters/TimeScale/scale = 1.0 +parameters/Tree/blend_position = 1.0 [node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" index="0"] position = Vector2(1, 11.5) diff --git a/scenes/entities/plants/peashooter.tscn b/scenes/entities/plants/peashooter.tscn index d9661db..aee5b0e 100644 --- a/scenes/entities/plants/peashooter.tscn +++ b/scenes/entities/plants/peashooter.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=21 format=3 uid="uid://dy41q1kxray5t"] +[gd_scene load_steps=23 format=3 uid="uid://dy41q1kxray5t"] [ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/templates/plant_template.tscn" id="1_pyk3o"] [ext_resource type="Texture2D" uid="uid://cksryh4w5dbbx" path="res://assets/sprites/atlases/plants/peashooter.png" id="2_14qlx"] @@ -31,6 +31,8 @@ _data = { &"RESET": SubResource("Animation_a2y0j") } +[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_mbbd7"] + [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_34v85"] animation = &"peashooter/idle" @@ -55,6 +57,14 @@ states/peashooter_shoot/node = SubResource("AnimationNodeAnimation_u4o2k") states/peashooter_shoot/position = Vector2(674, 82) transitions = ["Start", "peashooter_idle", SubResource("AnimationNodeStateMachineTransition_70n3m"), "peashooter_idle", "peashooter_shoot", SubResource("AnimationNodeStateMachineTransition_2lwpg"), "peashooter_shoot", "peashooter_idle", SubResource("AnimationNodeStateMachineTransition_k61yr")] +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_q58jr"] +graph_offset = Vector2(-518.8, 27.8) +nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_mbbd7") +nodes/TimeScale/position = Vector2(0, 120) +nodes/Tree/node = SubResource("AnimationNodeStateMachine_13o7y") +nodes/Tree/position = Vector2(-300, 120) +node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"] + [sub_resource type="SegmentShape2D" id="SegmentShape2D_8iovl"] resource_local_to_scene = true @@ -77,8 +87,9 @@ libraries = { autoplay = "peashooter/idle" [node name="AnimationTree" parent="." index="2"] -tree_root = SubResource("AnimationNodeStateMachine_13o7y") -parameters/conditions/ready = false +tree_root = SubResource("AnimationNodeBlendTree_q58jr") +parameters/TimeScale/scale = 1.0 +parameters/Tree/conditions/ready = false [node name="Shooter" type="Marker2D" parent="." index="3" node_paths=PackedStringArray("_timer")] position = Vector2(12, -4) diff --git a/scenes/entities/plants/potato_mine.tscn b/scenes/entities/plants/potato_mine.tscn index c53e617..4a12b17 100644 --- a/scenes/entities/plants/potato_mine.tscn +++ b/scenes/entities/plants/potato_mine.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=24 format=3 uid="uid://b5x35v3w2u8dx"] +[gd_scene load_steps=26 format=3 uid="uid://b5x35v3w2u8dx"] [ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/templates/plant_template.tscn" id="1_dj7ul"] [ext_resource type="Texture2D" uid="uid://c77o6ba0mw7a3" path="res://assets/sprites/atlases/plants/potato_mine.png" id="2_sneas"] @@ -10,6 +10,8 @@ [ext_resource type="AudioStream" uid="uid://dltjtpyfr1so0" path="res://assets/audio/sfx/potato_mine.mp3" id="8_3vqdc"] [ext_resource type="AudioStream" uid="uid://b27om1bw1x04e" path="res://assets/audio/sfx/dirt_rise.mp3" id="9_3vqdc"] +[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_3vqdc"] + [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_6uutc"] animation = &"potato_mine/explode" @@ -55,6 +57,14 @@ states/potato_mine_prime/position = Vector2(490.656, 75.168) transitions = ["Start", "potato_mine_idle_unprimed", SubResource("AnimationNodeStateMachineTransition_ttnxb"), "potato_mine_idle_unprimed", "potato_mine_prime", SubResource("AnimationNodeStateMachineTransition_8nvnf"), "potato_mine_explode", "End", SubResource("AnimationNodeStateMachineTransition_q0arb"), "potato_mine_prime", "potato_mine_idle_primed", SubResource("AnimationNodeStateMachineTransition_dikhn"), "potato_mine_idle_primed", "potato_mine_explode", SubResource("AnimationNodeStateMachineTransition_lqd1d")] graph_offset = Vector2(-16.3438, -67.832) +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_824aq"] +graph_offset = Vector2(-427, 79) +nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_3vqdc") +nodes/TimeScale/position = Vector2(100, 120) +nodes/Tree/node = SubResource("AnimationNodeStateMachine_nfn7b") +nodes/Tree/position = Vector2(-260, 140) +node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"] + [sub_resource type="CircleShape2D" id="CircleShape2D_v0g5b"] radius = 19.0263 @@ -69,13 +79,12 @@ size = Vector2(34, 19) [node name="Potato mine" instance=ExtResource("1_dj7ul")] MaxHP = 20.0 -_effectImmunities = Array[Resource]([]) [node name="Sprite2D" parent="." index="0"] texture = ExtResource("2_sneas") hframes = 7 vframes = 4 -frame = 7 +frame = 14 [node name="AnimationPlayer" parent="." index="1"] libraries = { @@ -84,9 +93,10 @@ libraries = { autoplay = "idle_unprimed" [node name="AnimationTree" parent="." index="2"] -tree_root = SubResource("AnimationNodeStateMachine_nfn7b") -parameters/conditions/explode = false -parameters/conditions/primed = false +tree_root = SubResource("AnimationNodeBlendTree_824aq") +parameters/TimeScale/scale = 1.0 +parameters/Tree/conditions/explode = false +parameters/Tree/conditions/primed = false [node name="Detectionbox" type="Area2D" parent="." index="3"] collision_layer = 0 diff --git a/scenes/entities/plants/snowpea.tscn b/scenes/entities/plants/snowpea.tscn index eb784f2..97fd65c 100644 --- a/scenes/entities/plants/snowpea.tscn +++ b/scenes/entities/plants/snowpea.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=14 format=3 uid="uid://b7innrovtmf5u"] +[gd_scene load_steps=16 format=3 uid="uid://b7innrovtmf5u"] [ext_resource type="PackedScene" uid="uid://dy41q1kxray5t" path="res://scenes/entities/plants/peashooter.tscn" id="1_lp85e"] [ext_resource type="Texture2D" uid="uid://cu0651pvvkmvm" path="res://assets/sprites/atlases/plants/snow_pea.png" id="2_ytrm0"] @@ -25,6 +25,8 @@ _data = { &"RESET": SubResource("Animation_pephc") } +[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_mbbd7"] + [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_dv2ad"] animation = &"snowpea/idle" @@ -49,6 +51,14 @@ states/snowpea_shoot/node = SubResource("AnimationNodeAnimation_ptach") states/snowpea_shoot/position = Vector2(682, 100) transitions = ["snowpea_shoot", "snowpea_idle", SubResource("AnimationNodeStateMachineTransition_8spty"), "Start", "snowpea_idle", SubResource("AnimationNodeStateMachineTransition_lshcr"), "snowpea_idle", "snowpea_shoot", SubResource("AnimationNodeStateMachineTransition_ihul0")] +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_3oyhk"] +graph_offset = Vector2(-518.8, 27.8) +nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_mbbd7") +nodes/TimeScale/position = Vector2(0, 120) +nodes/Tree/node = SubResource("AnimationNodeStateMachine_qdmro") +nodes/Tree/position = Vector2(-320, 100) +node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"] + [sub_resource type="SegmentShape2D" id="SegmentShape2D_3oyhk"] resource_local_to_scene = true @@ -65,7 +75,7 @@ libraries = { autoplay = "snowpea/idle" [node name="AnimationTree" parent="." index="2"] -tree_root = SubResource("AnimationNodeStateMachine_qdmro") +tree_root = SubResource("AnimationNodeBlendTree_3oyhk") [node name="Shooter" parent="." index="3"] _projectile = ExtResource("5_bv86m") diff --git a/scenes/entities/plants/spikeweed.tscn b/scenes/entities/plants/spikeweed.tscn index d44984d..6c669a8 100644 --- a/scenes/entities/plants/spikeweed.tscn +++ b/scenes/entities/plants/spikeweed.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 format=3 uid="uid://bdhod5c6o53ha"] +[gd_scene load_steps=12 format=3 uid="uid://bdhod5c6o53ha"] [ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/templates/plant_template.tscn" id="1_vmbvr"] [ext_resource type="Texture2D" uid="uid://coafh3mjharxo" path="res://assets/sprites/atlases/plants/spikeweed.png" id="2_ffrjr"] @@ -6,6 +6,8 @@ [ext_resource type="AnimationLibrary" uid="uid://cen6ku4y01dyg" path="res://resources/animations/plants/spikeweed.res" id="3_nwshn"] [ext_resource type="Script" uid="uid://dqquodxaijmem" path="res://scripts/components/plants/behaviours/SpikeweedBehaviour.cs" id="3_uhpn7"] +[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_jleqa"] + [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_lmfqg"] animation = &"spikeweed/idle" @@ -22,12 +24,19 @@ snap = 1.0 value_label = "attack" blend_mode = 1 +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_63okc"] +graph_offset = Vector2(-318, 108) +nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_jleqa") +nodes/TimeScale/position = Vector2(140, 140) +nodes/Tree/node = SubResource("AnimationNodeBlendSpace1D_1y7y3") +nodes/Tree/position = Vector2(-120, 180) +node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"] + [sub_resource type="RectangleShape2D" id="RectangleShape2D_1di76"] size = Vector2(49, 38) [node name="Spikeweed" instance=ExtResource("1_vmbvr")] MaxHP = 30.0 -_effectImmunities = Array[Resource]([]) [node name="Sprite2D" parent="." index="0"] texture = ExtResource("2_ffrjr") @@ -41,8 +50,9 @@ libraries = { } [node name="AnimationTree" parent="." index="2"] -tree_root = SubResource("AnimationNodeBlendSpace1D_1y7y3") -parameters/blend_position = 0.0 +tree_root = SubResource("AnimationNodeBlendTree_63okc") +parameters/TimeScale/scale = 1.0 +parameters/Tree/blend_position = 0 [node name="Behaviour" type="Node" parent="." index="3" node_paths=PackedStringArray("_tree")] script = ExtResource("3_uhpn7") diff --git a/scenes/entities/plants/sunflower.tscn b/scenes/entities/plants/sunflower.tscn index 045bc2f..cb0c035 100644 --- a/scenes/entities/plants/sunflower.tscn +++ b/scenes/entities/plants/sunflower.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=16 format=3 uid="uid://bg7lomiorxo2c"] +[gd_scene load_steps=18 format=3 uid="uid://bg7lomiorxo2c"] [ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/templates/plant_template.tscn" id="1_bikjn"] [ext_resource type="Texture2D" uid="uid://b3tuidu8dag8u" path="res://assets/sprites/atlases/plants/sunflower.png" id="2_fwcda"] @@ -12,7 +12,7 @@ length = 0.001 tracks/0/type = "value" tracks/0/imported = false tracks/0/enabled = true -tracks/0/path = NodePath("AnimationTree:parameters/conditions/produce") +tracks/0/path = NodePath("AnimationTree:parameters/Tree/conditions/produce") tracks/0/interp = 1 tracks/0/loop_wrap = true tracks/0/keys = { @@ -27,6 +27,8 @@ _data = { &"RESET": SubResource("Animation_bfx6v") } +[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_811ah"] + [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_lkpmx"] animation = &"sunflower/idle" @@ -51,18 +53,24 @@ states/sunflower_produce/node = SubResource("AnimationNodeAnimation_hc6hn") states/sunflower_produce/position = Vector2(624, 99) transitions = ["Start", "sunflower_idle", SubResource("AnimationNodeStateMachineTransition_26fia"), "sunflower_idle", "sunflower_produce", SubResource("AnimationNodeStateMachineTransition_d2akw"), "sunflower_produce", "sunflower_idle", SubResource("AnimationNodeStateMachineTransition_sww40")] +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_rlkb7"] +graph_offset = Vector2(-437, 84) +nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_811ah") +nodes/TimeScale/position = Vector2(100, 140) +nodes/Tree/node = SubResource("AnimationNodeStateMachine_enpal") +nodes/Tree/position = Vector2(-160, 180) +node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"] + [sub_resource type="RectangleShape2D" id="RectangleShape2D_4xs4g"] size = Vector2(26, 48) [node name="Sunflower" instance=ExtResource("1_bikjn")] MaxHP = 30.0 -_effectImmunities = Array[Resource]([]) [node name="Sprite2D" parent="." index="0"] texture = ExtResource("2_fwcda") hframes = 9 vframes = 2 -frame = 4 [node name="AnimationPlayer" parent="." index="1"] libraries = { @@ -71,8 +79,9 @@ libraries = { } [node name="AnimationTree" parent="." index="2"] -tree_root = SubResource("AnimationNodeStateMachine_enpal") -parameters/conditions/produce = false +tree_root = SubResource("AnimationNodeBlendTree_rlkb7") +parameters/TimeScale/scale = 1.0 +parameters/Tree/conditions/produce = false [node name="PlantSunSpawner" type="Node2D" parent="." index="3"] position = Vector2(-2, 0) diff --git a/scenes/entities/plants/threepeater.tscn b/scenes/entities/plants/threepeater.tscn index f9fedb5..bae2cac 100644 --- a/scenes/entities/plants/threepeater.tscn +++ b/scenes/entities/plants/threepeater.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=18 format=3 uid="uid://eegv1qihfv2q"] +[gd_scene load_steps=20 format=3 uid="uid://eegv1qihfv2q"] [ext_resource type="PackedScene" uid="uid://dy41q1kxray5t" path="res://scenes/entities/plants/peashooter.tscn" id="1_muntu"] [ext_resource type="Script" uid="uid://djpc0kvagpadv" path="res://scripts/components/plants/ThreepeaterShooter.cs" id="2_ieami"] @@ -94,6 +94,8 @@ _data = { &"shoot": SubResource("Animation_7kfrv") } +[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_mbbd7"] + [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_j7h7q"] animation = &"threepeater/idle" @@ -118,6 +120,14 @@ states/threepeater_shoot/node = SubResource("AnimationNodeAnimation_pqbws") states/threepeater_shoot/position = Vector2(633, 91) transitions = ["Start", "threepeater_idle", SubResource("AnimationNodeStateMachineTransition_7kfrv"), "threepeater_idle", "threepeater_shoot", SubResource("AnimationNodeStateMachineTransition_o2obw"), "threepeater_shoot", "threepeater_idle", SubResource("AnimationNodeStateMachineTransition_wiys2")] +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_j7h7q"] +graph_offset = Vector2(-518.8, 27.8) +nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_mbbd7") +nodes/TimeScale/position = Vector2(0, 120) +nodes/Tree/node = SubResource("AnimationNodeStateMachine_wiys2") +nodes/Tree/position = Vector2(-320, 100) +node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"] + [sub_resource type="SegmentShape2D" id="SegmentShape2D_j7h7q"] resource_local_to_scene = true @@ -138,7 +148,7 @@ libraries = { } [node name="AnimationTree" parent="." index="2"] -tree_root = SubResource("AnimationNodeStateMachine_wiys2") +tree_root = SubResource("AnimationNodeBlendTree_j7h7q") [node name="Shooter" parent="." index="3"] position = Vector2(20, -9) diff --git a/scenes/entities/plants/wallnut.tscn b/scenes/entities/plants/wallnut.tscn index dc796e0..76e6f40 100644 --- a/scenes/entities/plants/wallnut.tscn +++ b/scenes/entities/plants/wallnut.tscn @@ -1,10 +1,12 @@ -[gd_scene load_steps=10 format=3 uid="uid://bq7imkpr2yqyr"] +[gd_scene load_steps=12 format=3 uid="uid://bq7imkpr2yqyr"] [ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/templates/plant_template.tscn" id="1_fluxn"] [ext_resource type="Texture2D" uid="uid://dstqh1wc5dvmo" path="res://assets/sprites/atlases/plants/wallnut.png" id="2_o5tda"] [ext_resource type="AnimationLibrary" uid="uid://0bdesb8j2mbo" path="res://resources/animations/plants/wallnut.res" id="3_xl65q"] [ext_resource type="Script" uid="uid://btkmd86pn828y" path="res://scripts/components/plants/behaviours/HpBasedBehaviour.cs" id="4_cjtyy"] +[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_y3tlf"] + [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_ds5ry"] animation = &"wallnut/idle_full" @@ -24,18 +26,24 @@ blend_point_2/pos = 0.3 min_space = 0.0 blend_mode = 1 +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_bi7an"] +graph_offset = Vector2(-498, 95) +nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_y3tlf") +nodes/TimeScale/position = Vector2(60, 140) +nodes/Tree/node = SubResource("AnimationNodeBlendSpace1D_nij8v") +nodes/Tree/position = Vector2(-180, 180) +node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"] + [sub_resource type="RectangleShape2D" id="RectangleShape2D_khltr"] size = Vector2(33, 46) [node name="Wallnut" instance=ExtResource("1_fluxn")] MaxHP = 600.0 -_effectImmunities = Array[Resource]([]) [node name="Sprite2D" parent="." index="0"] texture = ExtResource("2_o5tda") hframes = 12 vframes = 3 -frame = 3 [node name="AnimationPlayer" parent="." index="1"] libraries = { @@ -43,8 +51,9 @@ libraries = { } [node name="AnimationTree" parent="." index="2"] -tree_root = SubResource("AnimationNodeBlendSpace1D_nij8v") -parameters/blend_position = 1.0 +tree_root = SubResource("AnimationNodeBlendTree_bi7an") +parameters/TimeScale/scale = 1.0 +parameters/Tree/blend_position = 1.0 [node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" index="0"] position = Vector2(3.5, 5) diff --git a/scenes/templates/plant_template.tscn b/scenes/templates/plant_template.tscn index 2266c6a..685838b 100644 --- a/scenes/templates/plant_template.tscn +++ b/scenes/templates/plant_template.tscn @@ -4,7 +4,6 @@ [node name="PlantTemplate" type="Node2D"] script = ExtResource("1_324sd") -_maxHP = 30 [node name="Sprite2D" type="Sprite2D" parent="."] use_parent_material = true diff --git a/scripts/components/Entity.cs b/scripts/components/Entity.cs index f4d181a..5d09167 100644 --- a/scripts/components/Entity.cs +++ b/scripts/components/Entity.cs @@ -44,13 +44,15 @@ public partial class Entity : Node2D #region Brain public virtual void DisableBrain() { - GetNode("AnimationPlayer").ProcessMode = ProcessModeEnum.Pausable; + GetNode("AnimationPlayer").ProcessMode = ProcessModeEnum.Always; + GetNode("AnimationTree").ProcessMode = ProcessModeEnum.Always; ProcessMode = ProcessModeEnum.Disabled; } public virtual void EnableBrain() { GetNode("AnimationPlayer").ProcessMode = ProcessModeEnum.Inherit; + GetNode("AnimationTree").ProcessMode = ProcessModeEnum.Inherit; ProcessMode = ProcessModeEnum.Inherit; } #endregion diff --git a/scripts/components/plants/behaviours/AloeBehaviour.cs b/scripts/components/plants/behaviours/AloeBehaviour.cs index f9dde56..3186709 100644 --- a/scripts/components/plants/behaviours/AloeBehaviour.cs +++ b/scripts/components/plants/behaviours/AloeBehaviour.cs @@ -17,7 +17,7 @@ public partial class AloeBehaviour : BaseBehaviour public override void _Process(double delta) { - _tree.Set("parameters/conditions/charged",_charge); + _tree.Set("parameters/Tree/conditions/charged",_charge); var checkPos = GetParent().GlobalPosition + Vector2.Right * Utility.TileWidth; if(_charge && PoolContainer.Instance.TryGetEntity(checkPos, out RuntimePlantData plantData)) @@ -25,7 +25,7 @@ public partial class AloeBehaviour : BaseBehaviour if((float)plantData.HP / (float)plantData.MaxHP < _hpTreshold) { _charge = false; - _tree.Set("parameters/conditions/heal",true); + _tree.Set("parameters/Tree/conditions/heal",true); _timer.Start(); } } diff --git a/scripts/components/plants/behaviours/HpBasedBehaviour.cs b/scripts/components/plants/behaviours/HpBasedBehaviour.cs index a234287..4c7fe1e 100644 --- a/scripts/components/plants/behaviours/HpBasedBehaviour.cs +++ b/scripts/components/plants/behaviours/HpBasedBehaviour.cs @@ -13,6 +13,6 @@ public partial class HpBasedBehaviour : BaseBehaviour public void OnHPChanged(int amount,Node origin) { - _tree.Set("parameters/blend_position",(float)_data.HP/_data.MaxHP); + _tree.Set("parameters/Tree/blend_position",(float)_data.HP/_data.MaxHP); } } diff --git a/scripts/components/plants/behaviours/PeashooterBehaviour.cs b/scripts/components/plants/behaviours/PeashooterBehaviour.cs index be36c8e..71d0568 100644 --- a/scripts/components/plants/behaviours/PeashooterBehaviour.cs +++ b/scripts/components/plants/behaviours/PeashooterBehaviour.cs @@ -11,6 +11,6 @@ public partial class PeashooterBehaviour : BaseBehaviour { bool readyToShoot = _sight.EnemyDetected && _shootTimer.TimeLeft <= 0; - _tree.Set("parameters/conditions/ready",readyToShoot); + _tree.Set("parameters/Tree/conditions/ready",readyToShoot); } } diff --git a/scripts/components/plants/behaviours/PotatomineBehaviour.cs b/scripts/components/plants/behaviours/PotatomineBehaviour.cs index 75c38c3..8f16553 100644 --- a/scripts/components/plants/behaviours/PotatomineBehaviour.cs +++ b/scripts/components/plants/behaviours/PotatomineBehaviour.cs @@ -10,7 +10,7 @@ public partial class PotatomineBehaviour : BaseBehaviour private bool _primed = false; public void Prime() { - _tree.Set("parameters/conditions/primed",true); + _tree.Set("parameters/Tree/conditions/primed",true); _hitbox.Monitorable = false; @@ -22,7 +22,7 @@ public partial class PotatomineBehaviour : BaseBehaviour public void OnAreaEntered(Area2D area) { if (_primed == false) return; - _tree.Set("parameters/conditions/explode",true); + _tree.Set("parameters/Tree/conditions/explode",true); _primed = false; } } diff --git a/scripts/components/plants/behaviours/SpikeweedBehaviour.cs b/scripts/components/plants/behaviours/SpikeweedBehaviour.cs index 7e4d3e6..2569966 100644 --- a/scripts/components/plants/behaviours/SpikeweedBehaviour.cs +++ b/scripts/components/plants/behaviours/SpikeweedBehaviour.cs @@ -2,20 +2,18 @@ using Godot; namespace Newlon.Components.Plants.Behaviours; -public partial class SpikeweedBehaviour : Node +public partial class SpikeweedBehaviour : BaseBehaviour { - [Export] private AnimationTree _tree; - private int _inCount = 0; public void OnHitboxEntered(Area2D _area) { if (_inCount++ == 0) - _tree.Set("parameters/blend_position",1); + _tree.Set("parameters/Tree/blend_position",1); } public void OnHitboxExited(Area2D _area) { if (--_inCount == 0) - _tree.Set("parameters/blend_position",0); + _tree.Set("parameters/Tree/blend_position",0); } } diff --git a/scripts/components/plants/behaviours/SunflowerBehaviour.cs b/scripts/components/plants/behaviours/SunflowerBehaviour.cs index 8672ac9..b01d703 100644 --- a/scripts/components/plants/behaviours/SunflowerBehaviour.cs +++ b/scripts/components/plants/behaviours/SunflowerBehaviour.cs @@ -2,18 +2,11 @@ using Godot; namespace Newlon.Components.Plants.Behaviours; -public partial class SunflowerBehaviour : Node +public partial class SunflowerBehaviour : BaseBehaviour { - private AnimationTree _tree; - - public override void _Ready() - { - _tree = GetNode("../AnimationTree"); - } - public void Timeout() { - _tree.Set("parameters/conditions/produce", true); + _tree.Set("parameters/Tree/conditions/produce", true); } }