@@ -12,27 +12,34 @@ namespace GodotModules.Netcode.Server
1212 public class GameServer : ENetServer
1313 {
1414 public static Dictionary < uint , DataPlayer > Players { get ; set ; }
15+ public static Dictionary < uint , Vector2 > LastSentPlayerPositions { get ; set ; }
1516 public static Timer TimerGameLoop { get ; set ; }
1617 public static Timer TimerNotifyClients { get ; set ; }
1718 public static float Delta { get ; set ; }
1819
1920 public GameServer ( )
2021 {
2122 Players = new Dictionary < uint , DataPlayer > ( ) ;
23+ LastSentPlayerPositions = new Dictionary < uint , Vector2 > ( ) ;
2224 TimerGameLoop = new Timer ( 16.67 ) ;
2325 TimerGameLoop . Elapsed += TimerGameLoopCallback ;
2426 TimerGameLoop . AutoReset = true ;
2527
26- TimerNotifyClients = new Timer ( 1000 ) ;
28+ TimerNotifyClients = new Timer ( 100 ) ;
2729 TimerNotifyClients . Elapsed += TimerNotifyClientsCallback ;
2830 TimerNotifyClients . AutoReset = true ;
2931 }
3032
3133 public void TimerNotifyClientsCallback ( System . Object source , ElapsedEventArgs args )
3234 {
35+ var playerPositions = Players . ToDictionary ( x => x . Key , x => x . Value . Position ) ;
36+ System . Console . WriteLine ( "DEBUG: " + playerPositions . Count ) ;
37+
3338 SendToAllPlayers ( ServerPacketOpcode . PlayerPositions , new SPacketPlayerPositions {
34- PlayerPositions = Players . ToDictionary ( x => x . Key , x => x . Value . Position )
39+ PlayerPositions = playerPositions
3540 } , PacketFlags . Reliable ) ;
41+
42+ LastSentPlayerPositions = playerPositions ;
3643 }
3744
3845 public void TimerGameLoopCallback ( System . Object source , ElapsedEventArgs args )
0 commit comments