private void OnDataMessage(NetIncomingMessage msg) { var type = (PacketType)msg.ReadByte(); if (type == PacketType.Connected) { InitializeFromServer(Packets.Connected.Read(msg)); } if (!Loaded) { return; } switch (type) { case PacketType.PlayerPreferences: PacketReceived(PlayerPreferences.Read(msg)); break; case PacketType.PlayerConnected: PacketReceived(PlayerConnected.Read(msg)); break; case PacketType.PlayerDisconnected: PacketReceived(PlayerDisconnected.Read(msg)); break; case PacketType.WorldState: AddWorldState(WorldState.Read(msg).worldState); break; case PacketType.PlayerDeath: PacketReceived(Packets.PlayerDeath.Read(msg)); break; case PacketType.PlayerShoot: PacketReceived(PlayerShoot.Read(msg)); break; case PacketType.ChangeLevel: PacketReceived(ChangeLevel.Read(msg)); break; case PacketType.GameOver: PacketReceived(Packets.GameOver.Read(msg)); break; } }