This repository was archived by the owner on Sep 15, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- using Timer = System . Timers . Timer ;
2-
31using ENet ;
42using Godot ;
53using GodotModules ;
64using GodotModules . Netcode ;
75using GodotModules . Netcode . Client ;
8- using System . Timers ;
96using System . Threading . Tasks ;
107
118namespace Game
@@ -16,7 +13,6 @@ public class ClientPlayer : OtherPlayer
1613 private Label LabelPosition { get ; set ; }
1714
1815 private float Speed = 250f ;
19- public static Timer EmitPosition { get ; set ; }
2016
2117 public override void _Ready ( )
2218 {
@@ -26,14 +22,15 @@ public override void _Ready()
2622
2723 if ( GameClient . Running )
2824 {
29- EmitPosition = new ( 1000 ) ;
30- EmitPosition . Elapsed += EmitPositionCallback ;
31- EmitPosition . AutoReset = true ;
32- EmitPosition . Enabled = true ;
25+ var timer = new Timer ( ) ;
26+ timer . Connect ( "timeout" , this , nameof ( EmitPosition ) ) ;
27+ timer . OneShot = false ;
28+ timer . Autostart = true ;
29+ AddChild ( timer ) ;
3330 }
3431 }
3532
36- public async void EmitPositionCallback ( System . Object source , ElapsedEventArgs args )
33+ public async void EmitPosition ( )
3734 {
3835 await GameClient . Send ( ClientPacketOpcode . PlayerPosition , new CPacketPlayerPosition {
3936 Position = Position
You can’t perform that action at this time.
0 commit comments