[gd_scene load_steps=19 format=3 uid="uid://h0af1dot82p3"]

[ext_resource type="Script" path="res://godot_state_charts_examples/platformer/breaking_box/breaking_box.gd" id="1_c2rh2"]
[ext_resource type="Texture2D" uid="uid://c5dogybcf6yfo" path="res://godot_state_charts_examples/platformer/breaking_box/idle.png" id="1_dixph"]
[ext_resource type="Script" path="res://addons/godot_state_charts/state_chart.gd" id="2_atynw"]
[ext_resource type="Texture2D" uid="uid://dq0ww6xvgeap3" path="res://godot_state_charts_examples/platformer/breaking_box/hit.png" id="3_ngvxc"]
[ext_resource type="Texture2D" uid="uid://p8vbysdruo4o" path="res://godot_state_charts_examples/platformer/breaking_box/break.png" id="4_jb7vf"]
[ext_resource type="Script" path="res://addons/godot_state_charts/compound_state.gd" id="5_wouwd"]
[ext_resource type="Script" path="res://addons/godot_state_charts/atomic_state.gd" id="6_p4jwe"]
[ext_resource type="Script" path="res://addons/godot_state_charts/transition.gd" id="7_1ecad"]
[ext_resource type="Script" path="res://addons/godot_state_charts/expression_guard.gd" id="8_8riiw"]

[sub_resource type="Animation" id="Animation_toibu"]
resource_name = "Break"
length = 0.3
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("BoxSprite:texture")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ExtResource("4_jb7vf")]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("BoxSprite:hframes")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [4]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("BoxSprite:frame")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0, 0.2),
"transitions": PackedFloat32Array(16.5643, 1),
"update": 0,
"values": [0, 3]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("Label:visible")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
tracks/4/type = "value"
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/path = NodePath("BoxCollider:disabled")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
tracks/5/type = "value"
tracks/5/imported = false
tracks/5/enabled = true
tracks/5/path = NodePath("BoxSprite:position")
tracks/5/interp = 1
tracks/5/loop_wrap = true
tracks/5/keys = {
"times": PackedFloat32Array(0, 0.2),
"transitions": PackedFloat32Array(1, 8.87654),
"update": 0,
"values": [Vector2(0, -10), Vector2(0, 50)]
}
tracks/6/type = "value"
tracks/6/imported = false
tracks/6/enabled = true
tracks/6/path = NodePath("BoxSprite:modulate:a")
tracks/6/interp = 1
tracks/6/loop_wrap = true
tracks/6/keys = {
"times": PackedFloat32Array(0, 0.2),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [1.0, 0.0]
}

[sub_resource type="Animation" id="Animation_rc67x"]
resource_name = "Hit"
length = 0.2
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("BoxSprite:texture")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ExtResource("3_ngvxc")]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("BoxSprite:hframes")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [2]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("BoxSprite:frame")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0, 0.1),
"transitions": PackedFloat32Array(1, 1),
"update": 1,
"values": [0, 1]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("Label:visible")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}

[sub_resource type="Animation" id="Animation_yu346"]
resource_name = "Idle"
length = 0.1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("BoxSprite:texture")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ExtResource("1_dixph")]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("BoxSprite:hframes")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [1]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("BoxSprite:frame")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [0]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("Label:visible")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
tracks/4/type = "value"
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/path = NodePath("BoxCollider:disabled")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}

[sub_resource type="Animation" id="Animation_a7q8m"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("BoxSprite:texture")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ExtResource("1_dixph")]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("BoxSprite:hframes")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [1]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("BoxSprite:frame")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [0]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("Label:visible")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
tracks/4/type = "value"
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/path = NodePath("BoxCollider:disabled")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
tracks/5/type = "value"
tracks/5/imported = false
tracks/5/enabled = true
tracks/5/path = NodePath("BoxSprite:position")
tracks/5/interp = 1
tracks/5/loop_wrap = true
tracks/5/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(0, -10)]
}
tracks/6/type = "value"
tracks/6/imported = false
tracks/6/enabled = true
tracks/6/path = NodePath("BoxSprite:modulate")
tracks/6/interp = 1
tracks/6/loop_wrap = true
tracks/6/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Color(1, 1, 1, 1)]
}

[sub_resource type="AnimationLibrary" id="AnimationLibrary_t7nrw"]
_data = {
"Break": SubResource("Animation_toibu"),
"Hit": SubResource("Animation_rc67x"),
"Idle": SubResource("Animation_yu346"),
"RESET": SubResource("Animation_a7q8m")
}

[sub_resource type="RectangleShape2D" id="RectangleShape2D_8vd2b"]

[sub_resource type="RectangleShape2D" id="RectangleShape2D_jbwph"]
size = Vector2(14.5, 2)

[sub_resource type="Resource" id="Resource_v858x"]
script = ExtResource("8_8riiw")
expression = "health > 0"

[sub_resource type="Resource" id="Resource_j86i4"]
script = ExtResource("8_8riiw")
expression = "health <= 0"

[node name="BreakingBox" type="StaticBody2D"]
input_pickable = true
script = ExtResource("1_c2rh2")

[node name="BoxSprite" type="Sprite2D" parent="."]
texture_filter = 1
position = Vector2(0, -10)
texture = ExtResource("1_dixph")

[node name="Label" type="Label" parent="."]
unique_name_in_owner = true
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -20.0
offset_top = -23.0
offset_right = 20.0
offset_bottom = 3.0
grow_horizontal = 2
grow_vertical = 2
theme_override_font_sizes/font_size = 10
text = "3"
horizontal_alignment = 1
vertical_alignment = 1

[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
unique_name_in_owner = true
editor_description = "The animation player will send an \"animation_finished\" event back to the state chart. This will then take the appropriate transitions (e.g. switch back to the idle animation)."
libraries = {
"": SubResource("AnimationLibrary_t7nrw")
}

[node name="BoxCollider" type="CollisionShape2D" parent="."]
position = Vector2(0, -10)
shape = SubResource("RectangleShape2D_8vd2b")

[node name="DetectionArea" type="Area2D" parent="."]
position = Vector2(0, -3)
collision_layer = 0

[node name="CollisionShape2D" type="CollisionShape2D" parent="DetectionArea"]
unique_name_in_owner = true
position = Vector2(0, -19)
shape = SubResource("RectangleShape2D_jbwph")

[node name="StateChart" type="Node" parent="."]
unique_name_in_owner = true
script = ExtResource("2_atynw")
track_in_editor = true

[node name="Root" type="Node" parent="StateChart"]
script = ExtResource("5_wouwd")
initial_state = NodePath("Idle")

[node name="Idle" type="Node" parent="StateChart/Root"]
script = ExtResource("6_p4jwe")

[node name="On Damage" type="Node" parent="StateChart/Root/Idle"]
script = ExtResource("7_1ecad")
to = NodePath("../../Blinking")
event = &"health_changed"
guard = SubResource("Resource_v858x")
delay_in_seconds = "0.0"

[node name="On Break" type="Node" parent="StateChart/Root/Idle"]
script = ExtResource("7_1ecad")
to = NodePath("../../Dying")
event = &"health_changed"
guard = SubResource("Resource_j86i4")
delay_in_seconds = "0.0"

[node name="Blinking" type="Node" parent="StateChart/Root"]
script = ExtResource("6_p4jwe")

[node name="Animation Finished" type="Node" parent="StateChart/Root/Blinking"]
script = ExtResource("7_1ecad")
to = NodePath("../../Idle")
event = &"animation_finished"
delay_in_seconds = "0.0"

[node name="Dying" type="Node" parent="StateChart/Root"]
script = ExtResource("6_p4jwe")

[node name="Animation Finished" type="Node" parent="StateChart/Root/Dying"]
script = ExtResource("7_1ecad")
to = NodePath("../../Dead")
event = &"animation_finished"
delay_in_seconds = "0.0"

[node name="Dead" type="Node" parent="StateChart/Root"]
script = ExtResource("6_p4jwe")

[connection signal="input_event" from="." to="." method="_on_input_event"]
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_animation_player_animation_finished"]
[connection signal="body_entered" from="DetectionArea" to="." method="_on_detection_area_body_entered"]
[connection signal="state_entered" from="StateChart/Root/Idle" to="." method="_on_idle_state_entered"]
[connection signal="state_entered" from="StateChart/Root/Blinking" to="." method="_on_blinking_state_entered"]
[connection signal="state_entered" from="StateChart/Root/Dying" to="." method="_on_dying_state_entered"]
[connection signal="state_entered" from="StateChart/Root/Dead" to="." method="_on_dead_state_entered"]
