Plants animation now supports timescale

This commit is contained in:
Rendo 2025-07-07 23:14:32 +05:00
commit e7a9860a54
18 changed files with 141 additions and 60 deletions

View file

@ -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="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"] [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/type = "value"
tracks/1/imported = false tracks/1/imported = false
tracks/1/enabled = true 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/interp = 1
tracks/1/loop_wrap = true tracks/1/loop_wrap = true
tracks/1/keys = { tracks/1/keys = {
@ -37,6 +37,8 @@ _data = {
&"RESET": SubResource("Animation_vknky") &"RESET": SubResource("Animation_vknky")
} }
[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_qtb3p"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_c25ew"] [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_c25ew"]
animation = &"aloe/heal" 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")] 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) 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"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_oe0dc"]
size = Vector2(22, 32) size = Vector2(22, 32)
[node name="Aloe" instance=ExtResource("1_n25yi")] [node name="Aloe" instance=ExtResource("1_n25yi")]
MaxHP = 30.0 MaxHP = 30.0
_effectImmunities = Array[Resource]([])
[node name="Sprite2D" parent="." index="0"] [node name="Sprite2D" parent="." index="0"]
position = Vector2(9, -14) position = Vector2(9, -14)
@ -100,9 +109,10 @@ libraries = {
} }
[node name="AnimationTree" parent="." index="2"] [node name="AnimationTree" parent="." index="2"]
tree_root = SubResource("AnimationNodeStateMachine_bldox") tree_root = SubResource("AnimationNodeBlendTree_gfy6j")
parameters/conditions/charged = false parameters/TimeScale/scale = 1.0
parameters/conditions/heal = false parameters/Tree/conditions/charged = false
parameters/Tree/conditions/heal = false
[node name="Behaviour" type="Node" parent="." index="3"] [node name="Behaviour" type="Node" parent="." index="3"]
script = ExtResource("4_55asm") script = ExtResource("4_55asm")

View file

@ -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="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"] [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") &"RESET": SubResource("Animation_k0cex")
} }
[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_2d3xk"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_mdv0r"] [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_mdv0r"]
animation = &"garlic/full_hp" animation = &"garlic/full_hp"
@ -46,12 +48,19 @@ blend_point_2/pos = 0.3
min_space = 0.0 min_space = 0.0
blend_mode = 1 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"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_thlvs"]
size = Vector2(32, 29) size = Vector2(32, 29)
[node name="Garlic" instance=ExtResource("1_5i0e6")] [node name="Garlic" instance=ExtResource("1_5i0e6")]
MaxHP = 200.0 MaxHP = 200.0
_effectImmunities = Array[Resource]([])
[node name="Sprite2D" parent="." index="0"] [node name="Sprite2D" parent="." index="0"]
texture = ExtResource("2_w2jbi") texture = ExtResource("2_w2jbi")
@ -65,8 +74,9 @@ libraries = {
} }
[node name="AnimationTree" parent="." index="2"] [node name="AnimationTree" parent="." index="2"]
tree_root = SubResource("AnimationNodeBlendSpace1D_8mvpm") tree_root = SubResource("AnimationNodeBlendTree_2o7sr")
parameters/blend_position = 1.0 parameters/TimeScale/scale = 1.0
parameters/Tree/blend_position = 1.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" index="0"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" index="0"]
position = Vector2(1, 11.5) position = Vector2(1, 11.5)

View file

@ -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="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"] [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") &"RESET": SubResource("Animation_a2y0j")
} }
[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_mbbd7"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_34v85"] [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_34v85"]
animation = &"peashooter/idle" animation = &"peashooter/idle"
@ -55,6 +57,14 @@ states/peashooter_shoot/node = SubResource("AnimationNodeAnimation_u4o2k")
states/peashooter_shoot/position = Vector2(674, 82) 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")] 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"] [sub_resource type="SegmentShape2D" id="SegmentShape2D_8iovl"]
resource_local_to_scene = true resource_local_to_scene = true
@ -77,8 +87,9 @@ libraries = {
autoplay = "peashooter/idle" autoplay = "peashooter/idle"
[node name="AnimationTree" parent="." index="2"] [node name="AnimationTree" parent="." index="2"]
tree_root = SubResource("AnimationNodeStateMachine_13o7y") tree_root = SubResource("AnimationNodeBlendTree_q58jr")
parameters/conditions/ready = false parameters/TimeScale/scale = 1.0
parameters/Tree/conditions/ready = false
[node name="Shooter" type="Marker2D" parent="." index="3" node_paths=PackedStringArray("_timer")] [node name="Shooter" type="Marker2D" parent="." index="3" node_paths=PackedStringArray("_timer")]
position = Vector2(12, -4) position = Vector2(12, -4)

View file

@ -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="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"] [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://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"] [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"] [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_6uutc"]
animation = &"potato_mine/explode" 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")] 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) 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"] [sub_resource type="CircleShape2D" id="CircleShape2D_v0g5b"]
radius = 19.0263 radius = 19.0263
@ -69,13 +79,12 @@ size = Vector2(34, 19)
[node name="Potato mine" instance=ExtResource("1_dj7ul")] [node name="Potato mine" instance=ExtResource("1_dj7ul")]
MaxHP = 20.0 MaxHP = 20.0
_effectImmunities = Array[Resource]([])
[node name="Sprite2D" parent="." index="0"] [node name="Sprite2D" parent="." index="0"]
texture = ExtResource("2_sneas") texture = ExtResource("2_sneas")
hframes = 7 hframes = 7
vframes = 4 vframes = 4
frame = 7 frame = 14
[node name="AnimationPlayer" parent="." index="1"] [node name="AnimationPlayer" parent="." index="1"]
libraries = { libraries = {
@ -84,9 +93,10 @@ libraries = {
autoplay = "idle_unprimed" autoplay = "idle_unprimed"
[node name="AnimationTree" parent="." index="2"] [node name="AnimationTree" parent="." index="2"]
tree_root = SubResource("AnimationNodeStateMachine_nfn7b") tree_root = SubResource("AnimationNodeBlendTree_824aq")
parameters/conditions/explode = false parameters/TimeScale/scale = 1.0
parameters/conditions/primed = false parameters/Tree/conditions/explode = false
parameters/Tree/conditions/primed = false
[node name="Detectionbox" type="Area2D" parent="." index="3"] [node name="Detectionbox" type="Area2D" parent="." index="3"]
collision_layer = 0 collision_layer = 0

View file

@ -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="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"] [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") &"RESET": SubResource("Animation_pephc")
} }
[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_mbbd7"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_dv2ad"] [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_dv2ad"]
animation = &"snowpea/idle" animation = &"snowpea/idle"
@ -49,6 +51,14 @@ states/snowpea_shoot/node = SubResource("AnimationNodeAnimation_ptach")
states/snowpea_shoot/position = Vector2(682, 100) 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")] 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"] [sub_resource type="SegmentShape2D" id="SegmentShape2D_3oyhk"]
resource_local_to_scene = true resource_local_to_scene = true
@ -65,7 +75,7 @@ libraries = {
autoplay = "snowpea/idle" autoplay = "snowpea/idle"
[node name="AnimationTree" parent="." index="2"] [node name="AnimationTree" parent="." index="2"]
tree_root = SubResource("AnimationNodeStateMachine_qdmro") tree_root = SubResource("AnimationNodeBlendTree_3oyhk")
[node name="Shooter" parent="." index="3"] [node name="Shooter" parent="." index="3"]
_projectile = ExtResource("5_bv86m") _projectile = ExtResource("5_bv86m")

View file

@ -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="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"] [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="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"] [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"] [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_lmfqg"]
animation = &"spikeweed/idle" animation = &"spikeweed/idle"
@ -22,12 +24,19 @@ snap = 1.0
value_label = "attack" value_label = "attack"
blend_mode = 1 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"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_1di76"]
size = Vector2(49, 38) size = Vector2(49, 38)
[node name="Spikeweed" instance=ExtResource("1_vmbvr")] [node name="Spikeweed" instance=ExtResource("1_vmbvr")]
MaxHP = 30.0 MaxHP = 30.0
_effectImmunities = Array[Resource]([])
[node name="Sprite2D" parent="." index="0"] [node name="Sprite2D" parent="." index="0"]
texture = ExtResource("2_ffrjr") texture = ExtResource("2_ffrjr")
@ -41,8 +50,9 @@ libraries = {
} }
[node name="AnimationTree" parent="." index="2"] [node name="AnimationTree" parent="." index="2"]
tree_root = SubResource("AnimationNodeBlendSpace1D_1y7y3") tree_root = SubResource("AnimationNodeBlendTree_63okc")
parameters/blend_position = 0.0 parameters/TimeScale/scale = 1.0
parameters/Tree/blend_position = 0
[node name="Behaviour" type="Node" parent="." index="3" node_paths=PackedStringArray("_tree")] [node name="Behaviour" type="Node" parent="." index="3" node_paths=PackedStringArray("_tree")]
script = ExtResource("3_uhpn7") script = ExtResource("3_uhpn7")

View file

@ -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="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"] [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/type = "value"
tracks/0/imported = false tracks/0/imported = false
tracks/0/enabled = true 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/interp = 1
tracks/0/loop_wrap = true tracks/0/loop_wrap = true
tracks/0/keys = { tracks/0/keys = {
@ -27,6 +27,8 @@ _data = {
&"RESET": SubResource("Animation_bfx6v") &"RESET": SubResource("Animation_bfx6v")
} }
[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_811ah"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_lkpmx"] [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_lkpmx"]
animation = &"sunflower/idle" animation = &"sunflower/idle"
@ -51,18 +53,24 @@ states/sunflower_produce/node = SubResource("AnimationNodeAnimation_hc6hn")
states/sunflower_produce/position = Vector2(624, 99) 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")] 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"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_4xs4g"]
size = Vector2(26, 48) size = Vector2(26, 48)
[node name="Sunflower" instance=ExtResource("1_bikjn")] [node name="Sunflower" instance=ExtResource("1_bikjn")]
MaxHP = 30.0 MaxHP = 30.0
_effectImmunities = Array[Resource]([])
[node name="Sprite2D" parent="." index="0"] [node name="Sprite2D" parent="." index="0"]
texture = ExtResource("2_fwcda") texture = ExtResource("2_fwcda")
hframes = 9 hframes = 9
vframes = 2 vframes = 2
frame = 4
[node name="AnimationPlayer" parent="." index="1"] [node name="AnimationPlayer" parent="." index="1"]
libraries = { libraries = {
@ -71,8 +79,9 @@ libraries = {
} }
[node name="AnimationTree" parent="." index="2"] [node name="AnimationTree" parent="." index="2"]
tree_root = SubResource("AnimationNodeStateMachine_enpal") tree_root = SubResource("AnimationNodeBlendTree_rlkb7")
parameters/conditions/produce = false parameters/TimeScale/scale = 1.0
parameters/Tree/conditions/produce = false
[node name="PlantSunSpawner" type="Node2D" parent="." index="3"] [node name="PlantSunSpawner" type="Node2D" parent="." index="3"]
position = Vector2(-2, 0) position = Vector2(-2, 0)

View file

@ -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="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"] [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") &"shoot": SubResource("Animation_7kfrv")
} }
[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_mbbd7"]
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_j7h7q"] [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_j7h7q"]
animation = &"threepeater/idle" animation = &"threepeater/idle"
@ -118,6 +120,14 @@ states/threepeater_shoot/node = SubResource("AnimationNodeAnimation_pqbws")
states/threepeater_shoot/position = Vector2(633, 91) 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")] 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"] [sub_resource type="SegmentShape2D" id="SegmentShape2D_j7h7q"]
resource_local_to_scene = true resource_local_to_scene = true
@ -138,7 +148,7 @@ libraries = {
} }
[node name="AnimationTree" parent="." index="2"] [node name="AnimationTree" parent="." index="2"]
tree_root = SubResource("AnimationNodeStateMachine_wiys2") tree_root = SubResource("AnimationNodeBlendTree_j7h7q")
[node name="Shooter" parent="." index="3"] [node name="Shooter" parent="." index="3"]
position = Vector2(20, -9) position = Vector2(20, -9)

View file

@ -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="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="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="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"] [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"] [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_ds5ry"]
animation = &"wallnut/idle_full" animation = &"wallnut/idle_full"
@ -24,18 +26,24 @@ blend_point_2/pos = 0.3
min_space = 0.0 min_space = 0.0
blend_mode = 1 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"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_khltr"]
size = Vector2(33, 46) size = Vector2(33, 46)
[node name="Wallnut" instance=ExtResource("1_fluxn")] [node name="Wallnut" instance=ExtResource("1_fluxn")]
MaxHP = 600.0 MaxHP = 600.0
_effectImmunities = Array[Resource]([])
[node name="Sprite2D" parent="." index="0"] [node name="Sprite2D" parent="." index="0"]
texture = ExtResource("2_o5tda") texture = ExtResource("2_o5tda")
hframes = 12 hframes = 12
vframes = 3 vframes = 3
frame = 3
[node name="AnimationPlayer" parent="." index="1"] [node name="AnimationPlayer" parent="." index="1"]
libraries = { libraries = {
@ -43,8 +51,9 @@ libraries = {
} }
[node name="AnimationTree" parent="." index="2"] [node name="AnimationTree" parent="." index="2"]
tree_root = SubResource("AnimationNodeBlendSpace1D_nij8v") tree_root = SubResource("AnimationNodeBlendTree_bi7an")
parameters/blend_position = 1.0 parameters/TimeScale/scale = 1.0
parameters/Tree/blend_position = 1.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" index="0"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" index="0"]
position = Vector2(3.5, 5) position = Vector2(3.5, 5)

View file

@ -4,7 +4,6 @@
[node name="PlantTemplate" type="Node2D"] [node name="PlantTemplate" type="Node2D"]
script = ExtResource("1_324sd") script = ExtResource("1_324sd")
_maxHP = 30
[node name="Sprite2D" type="Sprite2D" parent="."] [node name="Sprite2D" type="Sprite2D" parent="."]
use_parent_material = true use_parent_material = true

View file

@ -44,13 +44,15 @@ public partial class Entity : Node2D
#region Brain #region Brain
public virtual void DisableBrain() public virtual void DisableBrain()
{ {
GetNode<AnimationPlayer>("AnimationPlayer").ProcessMode = ProcessModeEnum.Pausable; GetNode<AnimationPlayer>("AnimationPlayer").ProcessMode = ProcessModeEnum.Always;
GetNode<AnimationTree>("AnimationTree").ProcessMode = ProcessModeEnum.Always;
ProcessMode = ProcessModeEnum.Disabled; ProcessMode = ProcessModeEnum.Disabled;
} }
public virtual void EnableBrain() public virtual void EnableBrain()
{ {
GetNode<AnimationPlayer>("AnimationPlayer").ProcessMode = ProcessModeEnum.Inherit; GetNode<AnimationPlayer>("AnimationPlayer").ProcessMode = ProcessModeEnum.Inherit;
GetNode<AnimationTree>("AnimationTree").ProcessMode = ProcessModeEnum.Inherit;
ProcessMode = ProcessModeEnum.Inherit; ProcessMode = ProcessModeEnum.Inherit;
} }
#endregion #endregion

View file

@ -17,7 +17,7 @@ public partial class AloeBehaviour : BaseBehaviour
public override void _Process(double delta) public override void _Process(double delta)
{ {
_tree.Set("parameters/conditions/charged",_charge); _tree.Set("parameters/Tree/conditions/charged",_charge);
var checkPos = GetParent<Node2D>().GlobalPosition + Vector2.Right * Utility.TileWidth; var checkPos = GetParent<Node2D>().GlobalPosition + Vector2.Right * Utility.TileWidth;
if(_charge && PoolContainer.Instance.TryGetEntity(checkPos, out RuntimePlantData plantData)) 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) if((float)plantData.HP / (float)plantData.MaxHP < _hpTreshold)
{ {
_charge = false; _charge = false;
_tree.Set("parameters/conditions/heal",true); _tree.Set("parameters/Tree/conditions/heal",true);
_timer.Start(); _timer.Start();
} }
} }

View file

@ -13,6 +13,6 @@ public partial class HpBasedBehaviour : BaseBehaviour
public void OnHPChanged(int amount,Node origin) 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);
} }
} }

View file

@ -11,6 +11,6 @@ public partial class PeashooterBehaviour : BaseBehaviour
{ {
bool readyToShoot = _sight.EnemyDetected && _shootTimer.TimeLeft <= 0; bool readyToShoot = _sight.EnemyDetected && _shootTimer.TimeLeft <= 0;
_tree.Set("parameters/conditions/ready",readyToShoot); _tree.Set("parameters/Tree/conditions/ready",readyToShoot);
} }
} }

View file

@ -10,7 +10,7 @@ public partial class PotatomineBehaviour : BaseBehaviour
private bool _primed = false; private bool _primed = false;
public void Prime() public void Prime()
{ {
_tree.Set("parameters/conditions/primed",true); _tree.Set("parameters/Tree/conditions/primed",true);
_hitbox.Monitorable = false; _hitbox.Monitorable = false;
@ -22,7 +22,7 @@ public partial class PotatomineBehaviour : BaseBehaviour
public void OnAreaEntered(Area2D area) public void OnAreaEntered(Area2D area)
{ {
if (_primed == false) return; if (_primed == false) return;
_tree.Set("parameters/conditions/explode",true); _tree.Set("parameters/Tree/conditions/explode",true);
_primed = false; _primed = false;
} }
} }

View file

@ -2,20 +2,18 @@ using Godot;
namespace Newlon.Components.Plants.Behaviours; namespace Newlon.Components.Plants.Behaviours;
public partial class SpikeweedBehaviour : Node public partial class SpikeweedBehaviour : BaseBehaviour
{ {
[Export] private AnimationTree _tree;
private int _inCount = 0; private int _inCount = 0;
public void OnHitboxEntered(Area2D _area) public void OnHitboxEntered(Area2D _area)
{ {
if (_inCount++ == 0) if (_inCount++ == 0)
_tree.Set("parameters/blend_position",1); _tree.Set("parameters/Tree/blend_position",1);
} }
public void OnHitboxExited(Area2D _area) public void OnHitboxExited(Area2D _area)
{ {
if (--_inCount == 0) if (--_inCount == 0)
_tree.Set("parameters/blend_position",0); _tree.Set("parameters/Tree/blend_position",0);
} }
} }

View file

@ -2,18 +2,11 @@ using Godot;
namespace Newlon.Components.Plants.Behaviours; 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>("../AnimationTree");
}
public void Timeout() public void Timeout()
{ {
_tree.Set("parameters/conditions/produce", true); _tree.Set("parameters/Tree/conditions/produce", true);
} }
} }