@@ -8,7 +8,7 @@ public class ServerSimulation : Node
88 private static ConcurrentQueue < ThreadCmd < SimulationOpcode > > ServerSimulationQueue = new ConcurrentQueue < ThreadCmd < SimulationOpcode > > ( ) ;
99
1010 public static Dictionary < ushort , Enemy > Enemies = new Dictionary < ushort , Enemy > ( ) ;
11- public static Dictionary < byte , Game . OtherPlayer > Players = new Dictionary < byte , Game . OtherPlayer > ( ) ;
11+ private Dictionary < byte , Game . OtherPlayer > Players ;
1212
1313 private static ServerSimulation Instance { get ; set ; }
1414 private static GTimer Timer { get ; set ; }
@@ -17,6 +17,7 @@ public class ServerSimulation : Node
1717 public override void _Ready ( )
1818 {
1919 Instance = this ;
20+ Players = new Dictionary < byte , Game . OtherPlayer > ( ) ;
2021 Timer = new GTimer ( ServerIntervals . PlayerTransforms , true , false ) ;
2122 Timer . Connect ( this , nameof ( EmitSimulationData ) ) ;
2223 }
@@ -36,7 +37,7 @@ public override void _PhysicsProcess(float delta)
3637
3738 public static void Enqueue ( ThreadCmd < SimulationOpcode > cmd ) => ServerSimulationQueue . Enqueue ( cmd ) ;
3839
39- public static void Dequeue ( )
40+ public void Dequeue ( )
4041 {
4142 if ( ServerSimulationQueue . TryDequeue ( out ThreadCmd < SimulationOpcode > cmd ) )
4243 {
@@ -77,7 +78,7 @@ public static void Dequeue()
7778 }
7879 }
7980
80- private static void CreatePlayer ( byte id )
81+ private void CreatePlayer ( byte id )
8182 {
8283 var otherPlayer = Prefabs . OtherPlayer . Instance < Game . OtherPlayer > ( ) ;
8384 otherPlayer . AddToGroup ( "Player" ) ;
@@ -86,10 +87,11 @@ private static void CreatePlayer(byte id)
8687 Instance . AddChild ( otherPlayer ) ;
8788 }
8889
89- private static void CreateEnemy ( SimulationEnemy simEnemy )
90+ private void CreateEnemy ( SimulationEnemy simEnemy )
9091 {
9192 var enemy = Prefabs . Enemy . Instance < Enemy > ( ) ;
9293 enemy . AddToGroup ( "Enemy" ) ;
94+ enemy . SetPlayers ( Players ) ;
9395 enemy . Position = simEnemy . SpawnForce ;
9496 Enemies . Add ( simEnemy . Id , enemy ) ;
9597 Instance . AddChild ( enemy ) ;
@@ -105,7 +107,7 @@ private void EmitSimulationData()
105107 NetworkManager . GameServer . ENetCmds . Enqueue ( new ThreadCmd < ENetOpcode > ( ENetOpcode . EnemyTransforms , enemyData ) ) ;
106108 }
107109
108- public static void Cleanup ( )
110+ public void Cleanup ( )
109111 {
110112 Timer . Stop ( ) ;
111113 while ( ServerSimulationQueue . TryDequeue ( out _ ) ) ;
0 commit comments