Example #1
0
        private void OnPlayerTeamUpdate(ushort id, ServerPlayerTeamUpdate teamUpdate)
        {
            if (!_playerData.TryGetValue(id, out var playerData))
            {
                Logger.Get().Warn(this, $"Received PlayerTeamUpdate data, but player with ID {id} is not in mapping");
                return;
            }

            Logger.Get().Info(this, $"Received PlayerTeamUpdate data from ID: {id}, new team: {teamUpdate.Team}");

            // Update the team in the player data
            playerData.Team = teamUpdate.Team;

            // Broadcast the packet to all players except the player we received the update from
            foreach (var playerId in _playerData.GetCopy().Keys)
            {
                if (id == playerId)
                {
                    continue;
                }

                _netServer.GetUpdateManagerForClient(playerId).AddPlayerTeamUpdateData(
                    id,
                    playerData.Username,
                    teamUpdate.Team
                    );
            }
        }
Example #2
0
        public ServerUpdatePacket(Packet packet) : base(packet)
        {
            DataPacketIds = new HashSet <ServerPacketId>();

            HelloServer = new HelloServer();

            PlayerUpdate  = new PlayerUpdate();
            EntityUpdates = new PacketDataCollection <EntityUpdate>();

            PlayerEnterScene  = new ServerPlayerEnterScene();
            PlayerTeamUpdate  = new ServerPlayerTeamUpdate();
            PlayerSkinUpdate  = new ServerPlayerSkinUpdate();
            PlayerEmoteUpdate = new ServerPlayerEmoteUpdate();
        }