[gd_scene load_steps=11 format=3 uid="uid://b18rv6o4duide"]

[ext_resource type="Texture2D" uid="uid://bgw8xgbwc2flx" path="res://godot_state_charts_examples/history_states/white_rectangle.svg" id="1_3v23e"]
[ext_resource type="PackedScene" uid="uid://bcwkugn6v3oy7" path="res://addons/godot_state_charts/utilities/state_chart_debugger.tscn" id="2_fgw1q"]
[ext_resource type="Script" path="res://addons/godot_state_charts/state_chart.gd" id="2_pqmip"]
[ext_resource type="Script" path="res://godot_state_charts_examples/history_states/history_demo.gd" id="2_vphtk"]
[ext_resource type="Script" path="res://addons/godot_state_charts/compound_state.gd" id="3_nsw2j"]
[ext_resource type="Script" path="res://addons/godot_state_charts/history_state.gd" id="4_0qaqv"]
[ext_resource type="Script" path="res://addons/godot_state_charts/atomic_state.gd" id="5_lh5sp"]
[ext_resource type="Script" path="res://addons/godot_state_charts/transition.gd" id="6_xvm5g"]
[ext_resource type="Theme" uid="uid://s2bj74tt0y7f" path="res://godot_state_charts_examples/new_theme.tres" id="8_najew"]

[sub_resource type="RectangleShape2D" id="RectangleShape2D_kl3ga"]
size = Vector2(34.243, 33.536)

[node name="Node" type="Node"]
script = ExtResource("2_vphtk")

[node name="StateChartDebugger" parent="." instance=ExtResource("2_fgw1q")]
offset_left = 280.0
offset_top = 9.0
offset_right = -12.0
offset_bottom = -190.0
theme = ExtResource("8_najew")
initial_node_to_watch = NodePath("../StateChart")

[node name="Node2D" type="Sprite2D" parent="."]
position = Vector2(145, 206)
scale = Vector2(6.6875, 3.90625)
texture = ExtResource("1_3v23e")

[node name="Area2D" type="Area2D" parent="Node2D"]

[node name="CollisionShape2D" type="CollisionShape2D" parent="Node2D/Area2D"]
position = Vector2(0.0747795, 3.8147e-06)
shape = SubResource("RectangleShape2D_kl3ga")

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

[node name="Root" type="Node" parent="StateChart"]
script = ExtResource("3_nsw2j")
initial_state = NodePath("Red Or Blue")

[node name="Red Or Blue" type="Node" parent="StateChart/Root"]
script = ExtResource("3_nsw2j")
initial_state = NodePath("Red")

[node name="Resume" type="Node" parent="StateChart/Root/Red Or Blue"]
script = ExtResource("4_0qaqv")
default_state = NodePath("../Red")

[node name="Red" type="Node" parent="StateChart/Root/Red Or Blue"]
script = ExtResource("5_lh5sp")

[node name="To Blue" type="Node" parent="StateChart/Root/Red Or Blue/Red"]
script = ExtResource("6_xvm5g")
to = NodePath("../../Blue")
delay_seconds = 3.0

[node name="Blue" type="Node" parent="StateChart/Root/Red Or Blue"]
script = ExtResource("5_lh5sp")

[node name="To Red" type="Node" parent="StateChart/Root/Red Or Blue/Blue"]
script = ExtResource("6_xvm5g")
to = NodePath("../../Red")
delay_seconds = 3.0

[node name="On Clicked To White" type="Node" parent="StateChart/Root/Red Or Blue"]
script = ExtResource("6_xvm5g")
to = NodePath("../../White")
event = &"clicked"

[node name="White" type="Node" parent="StateChart/Root"]
script = ExtResource("5_lh5sp")

[node name="Resume" type="Node" parent="StateChart/Root/White"]
script = ExtResource("6_xvm5g")
to = NodePath("../../Red Or Blue/Resume")
delay_seconds = 1.0

[node name="Label" type="RichTextLabel" parent="."]
offset_left = 26.0
offset_top = 318.0
offset_right = 376.0
offset_bottom = 416.0
mouse_filter = 2
bbcode_enabled = true
text = "[font_size=10]
[ul]
The rectangle will switch from red to blue every 3 seconds.
When you click the rectangle it will temporarily turn white and then return to whatever color it was previously by transitioning to the \"Resume\" state. The timer will also be properly restored, so the previously active color will remain active for the rest of the 5 seconds.
[/ul]
[/font_size]"
fit_content = true

[connection signal="input_event" from="Node2D/Area2D" to="." method="_on_area_2d_input_event"]
[connection signal="state_entered" from="StateChart/Root/Red Or Blue/Red" to="Node2D" method="set_modulate" binds= [Color(1, 0.231373, 0.172549, 1)]]
[connection signal="state_entered" from="StateChart/Root/Red Or Blue/Blue" to="Node2D" method="set_modulate" binds= [Color(0.286275, 0.501961, 1, 1)]]
[connection signal="state_entered" from="StateChart/Root/White" to="Node2D" method="set_modulate" binds= [Color(1, 1, 1, 1)]]
