public override void ProcessPacket(Guid sourcePlayerId, Packet packet, IProcessorContext context)
        {
            PlayerDataUpdatedPacket playerDataUpdatedPacket = (PlayerDataUpdatedPacket)packet;
            ClientProcessorContext  processorContext        = (ClientProcessorContext)context;

            processorContext.Client.PlayerManager.OnPlayerUpdated(playerDataUpdatedPacket.PlayerId, playerDataUpdatedPacket.Player);
            if (playerDataUpdatedPacket.Player == processorContext.Client.LocalPlayer)
            {
                // Update the local client data
                processorContext.Client.LocalPlayer = playerDataUpdatedPacket.Player;
            }
        }
Ejemplo n.º 2
0
        public bool UpdatePlayer(Guid playerId, Player player)
        {
            bool flag = connectedPlayers.ContainsKey(playerId);

            if (flag)
            {
                connectedPlayers[playerId] = player;
            }

            Console.WriteLine($"Player updated: {playerId}");

            PlayerDataUpdatedPacket playerDataUpdatedPacket = new PlayerDataUpdatedPacket(playerId, player);

            server.SendPacketToAll(playerDataUpdatedPacket);

            PlayerEventArgs playerEventArgs = new PlayerEventArgs(playerId);

            PlayerUpdated?.Invoke(this, playerEventArgs);

            return(flag);
        }