Esempio n. 1
0
        /// <summary>
        /// Synchronizes the User's stat values to the client.
        /// </summary>
        public void UpdateClient(INetworkSender sendTo)
        {
            if (!_anyStatsChanged)
            {
                return;
            }

            // Check if any stat values have changed
            var statsToUpdate = _changedStats.GetChangedStats();

            if (statsToUpdate.IsEmpty())
            {
                return;
            }

            // Build a packet containing all the new stat values and send it to the user
            using (var pw = ServerPacket.GetWriter())
            {
                foreach (var stat in statsToUpdate)
                {
                    ServerPacket.UpdateStat(pw, stat, StatCollectionType);
                }

                sendTo.Send(pw, ServerMessageType.GUIUserStats);
            }

            _anyStatsChanged = false;
        }