gd,refacto: added state chart addon and namespace cleanup

This commit is contained in:
2025-06-05 14:47:51 +02:00
parent 8818e77d23
commit 5c36765a36
239 changed files with 10430 additions and 115 deletions

View File

@ -0,0 +1,11 @@
extends Node
@onready var state_chart:StateChart = $StateChart
func _on_area_2d_input_event(_viewport:Node, event:InputEvent, _shape_idx:int):
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT:
# on release send clicked event to state chart
if not event.is_pressed():
state_chart.send_event("clicked")

View File

@ -0,0 +1 @@
uid://bad613wfktgah

View File

@ -0,0 +1,102 @@
[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_in_seconds = "3"
[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_in_seconds = "3"
[node name="On Clicked To White" type="Node" parent="StateChart/Root/Red Or Blue"]
script = ExtResource("6_xvm5g")
to = NodePath("../../White")
event = &"clicked"
delay_in_seconds = "0.0"
[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_in_seconds = "1"
[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)]]

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<rect id="Artboard1" x="0" y="0" width="32" height="32" style="fill:none;"/>
<clipPath id="_clip1">
<rect id="Artboard11" serif:id="Artboard1" x="0" y="0" width="32" height="32"/>
</clipPath>
<g clip-path="url(#_clip1)">
<g transform="matrix(1.018,0,0,1.02155,-0.335834,-0.355613)">
<rect x="0.33" y="0.348" width="31.434" height="31.325" style="fill:rgb(235,235,235);"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 888 B

View File

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bgw8xgbwc2flx"
path="res://.godot/imported/white_rectangle.svg-4d0041e2d5db811b29367f0371ead08c.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://godot_state_charts_examples/history_states/white_rectangle.svg"
dest_files=["res://.godot/imported/white_rectangle.svg-4d0041e2d5db811b29367f0371ead08c.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
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false