Pārlūkot izejas kodu

:truck: Move routing and pause logic in dedicated component

In order to make pause resume possible.
DricomDragon 2 gadi atpakaļ
vecāks
revīzija
15a5e88135

+ 0 - 9
godot/component/entity/level/Level.gd

@@ -1,9 +0,0 @@
-extends Node2D
-
-
-const MENU_FILE: String = "res://run/menu.tscn"
-
-
-func _input(event: InputEvent) -> void:
-	if event.is_action_pressed("ui_cancel"):
-		get_tree().change_scene_to_file(MENU_FILE)

+ 21 - 0
godot/component/manage/router/Router.gd

@@ -0,0 +1,21 @@
+extends Node
+
+
+const MENU_FILE: String = "res://run/menu.tscn"
+
+
+func _input(event: InputEvent) -> void:
+	if event.is_action_pressed("ui_cancel"):
+		go_back_to_menu()
+	if event.is_action_pressed("ui_accept"):
+		toggle_pause()
+
+
+func go_back_to_menu():
+	get_tree().set_pause(false)
+	get_tree().change_scene_to_file(MENU_FILE)
+
+
+func toggle_pause():
+	var current_status: bool = get_tree().is_paused()
+	get_tree().set_pause(!current_status)

+ 7 - 0
godot/component/manage/router/Router.tscn

@@ -0,0 +1,7 @@
+[gd_scene load_steps=2 format=3]
+
+[ext_resource type="Script" path="res://component/manage/router/Router.gd" id="1_uo1vg"]
+
+[node name="Router" type="Node"]
+process_mode = 3
+script = ExtResource("1_uo1vg")

+ 5 - 4
godot/run/levels/heart.tscn

@@ -1,7 +1,7 @@
-[gd_scene load_steps=9 format=3 uid="uid://38l0xifohua4"]
+[gd_scene load_steps=9 format=3 uid="uid://cm11n13hpeyrm"]
 
 [ext_resource type="PackedScene" uid="uid://bw4uy776cvn5o" path="res://component/entity/line/Line.tscn" id="1_80o1x"]
-[ext_resource type="Script" path="res://component/entity/level/Level.gd" id="1_nqh2i"]
+[ext_resource type="PackedScene" path="res://component/manage/router/Router.tscn" id="1_o1ujs"]
 [ext_resource type="PackedScene" uid="uid://bs4hylgxwbr8y" path="res://component/entity/star/Star.tscn" id="2_cc0ak"]
 [ext_resource type="PackedScene" uid="uid://dkltla4rn3vgv" path="res://component/entity/trigger/Trigger.tscn" id="3_1jckh"]
 
@@ -29,8 +29,9 @@ _data = {
 }
 point_count = 7
 
-[node name="Root" type="Node2D"]
-script = ExtResource("1_nqh2i")
+[node name="HeartLevel" type="Node2D"]
+
+[node name="Router" parent="." instance=ExtResource("1_o1ujs")]
 
 [node name="Lines" type="Node2D" parent="."]
 

+ 4 - 3
godot/run/levels/simple_scales.tscn

@@ -1,12 +1,13 @@
-[gd_scene load_steps=5 format=3 uid="uid://bwvywnh4itqg3"]
+[gd_scene load_steps=5 format=3 uid="uid://bmdqfw4sxhdt3"]
 
+[ext_resource type="PackedScene" path="res://component/manage/router/Router.tscn" id="1_8gknq"]
 [ext_resource type="PackedScene" uid="uid://bw4uy776cvn5o" path="res://component/entity/line/Line.tscn" id="1_bt0a1"]
-[ext_resource type="Script" path="res://component/entity/level/Level.gd" id="1_sbrp4"]
 [ext_resource type="PackedScene" uid="uid://bs4hylgxwbr8y" path="res://component/entity/star/Star.tscn" id="2_k3r0g"]
 [ext_resource type="PackedScene" uid="uid://dkltla4rn3vgv" path="res://component/entity/trigger/Trigger.tscn" id="3_81otn"]
 
 [node name="Root" type="Node2D"]
-script = ExtResource("1_sbrp4")
+
+[node name="Router" parent="." instance=ExtResource("1_8gknq")]
 
 [node name="MainLine" parent="." instance=ExtResource("1_bt0a1")]
 

+ 3 - 2
godot/run/levels/world.tscn

@@ -1,7 +1,7 @@
 [gd_scene load_steps=7 format=3 uid="uid://bs8crkburdpjc"]
 
+[ext_resource type="PackedScene" path="res://component/manage/router/Router.tscn" id="1_mao16"]
 [ext_resource type="PackedScene" uid="uid://bs4hylgxwbr8y" path="res://component/entity/star/Star.tscn" id="1_wa4bn"]
-[ext_resource type="Script" path="res://component/entity/level/Level.gd" id="1_xs4im"]
 [ext_resource type="PackedScene" uid="uid://dkltla4rn3vgv" path="res://component/entity/trigger/Trigger.tscn" id="3_h3i8n"]
 [ext_resource type="PackedScene" uid="uid://bw4uy776cvn5o" path="res://component/entity/line/Line.tscn" id="3_l2vrj"]
 
@@ -18,7 +18,8 @@ _data = {
 point_count = 11
 
 [node name="World" type="Node2D"]
-script = ExtResource("1_xs4im")
+
+[node name="Router" parent="." instance=ExtResource("1_mao16")]
 
 [node name="Lines" type="Node2D" parent="."]