This repository was archived by the owner on Sep 15, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +21
-19
lines changed Expand file tree Collapse file tree 5 files changed +21
-19
lines changed Original file line number Diff line number Diff line change 1- [gd_scene load_steps =7 format =2 ]
1+ [gd_scene load_steps =8 format =2 ]
22
33[ext_resource path ="res://Scripts/Scenes/Main/GameManager.cs" type ="Script" id =1 ]
44[ext_resource path ="res://Scripts/Scenes/Main/MusicManager.cs" type ="Script" id =2 ]
55[ext_resource path ="res://Scripts/Scenes/Main/Debug.cs" type ="Script" id =3 ]
66[ext_resource path ="res://Scripts/Scenes/Main/NetworkManager.cs" type ="Script" id =4 ]
77[ext_resource path ="res://Scripts/Scenes/Main/SceneManager.cs" type ="Script" id =5 ]
88[ext_resource path ="res://Scenes/Prefabs/Debugger.tscn" type ="PackedScene" id =6 ]
9+ [ext_resource path ="res://Scripts/Scenes/Main/ErrorNotifier.cs" type ="Script" id =7 ]
910
1011[node name ="Main" type ="Node" ]
1112script = ExtResource ( 1 )
@@ -23,6 +24,9 @@ script = ExtResource( 4 )
2324[node name ="SceneManager" type ="Node" parent ="." ]
2425script = ExtResource ( 5 )
2526
27+ [node name ="ErrorNotifier" type ="Node" parent ="." ]
28+ script = ExtResource ( 7 )
29+
2630[node name ="CanvasLayer" type ="CanvasLayer" parent ="." ]
2731
2832[node name ="Debugger" parent ="CanvasLayer" instance =ExtResource ( 6 )]
Original file line number Diff line number Diff line change @@ -11,10 +11,12 @@ public class UINotifyError : Control
1111 private Label ErrorCount { get ; set ; }
1212 private AnimationPlayer AnimationPlayer { get ; set ; }
1313
14- public async void Init ( int count )
14+ public int Count { get ; set ; }
15+
16+ public override async void _Ready ( )
1517 {
1618 ErrorCount = GetNode < Label > ( NodePathErrorCount ) ;
17- ErrorCount . Text = $ "{ count } ";
19+ ErrorCount . Text = $ "{ Count } ";
1820 AnimationPlayer = GetNode < AnimationPlayer > ( NodePathAnimationPlayer ) ;
1921 AnimationPlayer . Play ( "Appear" ) ;
2022 await Task . Delay ( 2000 ) ;
Original file line number Diff line number Diff line change 1- using System . Timers ;
1+ using Godot ;
22
33namespace GodotModules
44{
5- public static class ErrorNotifier
5+ public class ErrorNotifier : Node
66 {
7- private static Timer TimerErrorNotifier { get ; set ; }
87 private static int ErrorCount { get ; set ; }
9-
108 public static void IncrementErrorCount ( ) => ErrorCount ++ ;
119
12- public static void StartInterval ( int seconds )
10+ public override void _Ready ( )
1311 {
14- TimerErrorNotifier = new ( seconds * 1000 ) ;
15- TimerErrorNotifier . Elapsed += SpawnErrorNotification ;
16- TimerErrorNotifier . AutoReset = true ;
17- TimerErrorNotifier . Enabled = true ;
12+ var timer = new Timer ( ) ;
13+ timer . Connect ( "timeout" , this , nameof ( SpawnErrorNotification ) ) ;
14+ timer . WaitTime = 1.5f ;
15+ timer . OneShot = false ;
16+ timer . Autostart = true ;
17+ AddChild ( timer ) ;
1818 }
1919
20- public static void Dispose ( ) => TimerErrorNotifier . Dispose ( ) ;
21-
22- private static void SpawnErrorNotification ( System . Object source , ElapsedEventArgs args )
20+ private static void SpawnErrorNotification ( )
2321 {
2422 if ( ErrorCount == 0 )
2523 return ;
2624
2725 var notifyError = Prefabs . NotifyError . Instance < UINotifyError > ( ) ;
28- notifyError . Init ( ErrorCount ) ;
29- GameManager . Instance . CallDeferred ( "add_child" , notifyError ) ;
26+ notifyError . Count = ErrorCount ;
27+ GameManager . Instance . AddChild ( notifyError ) ;
3028
3129 ErrorCount = 0 ;
3230 }
Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ public class GameManager : Node
2222 public override void _Ready ( )
2323 {
2424 Instance = this ;
25- ErrorNotifier . StartInterval ( 2 ) ;
2625 }
2726
2827 public override void _Input ( InputEvent @event )
Original file line number Diff line number Diff line change @@ -114,7 +114,6 @@ private static async Task ExitCleanup()
114114
115115 UtilOptions . SaveOptions ( ) ;
116116 WebClient . Client . Dispose ( ) ;
117- ErrorNotifier . Dispose ( ) ;
118117
119118 ClientConnectingTokenSource ? . Dispose ( ) ;
120119
You can’t perform that action at this time.
0 commit comments