示例#1
0
        /// <summary>
        /// Writes the specified fields to an outgoing message.
        /// </summary>
        /// <param name="message">The outgoing message</param>
        /// <param name="includedFields">Indicates the fields that must synchronized</param>
        protected void WriteToMessage(OutgoingMessage message, PlayerFliedsFlags includedFields)
        {
            message.Write((byte)includedFields);

            if (includedFields.HasFlag(PlayerFliedsFlags.Nickname))
            {
                message.Write(this.Nickname);
            }

            if (includedFields.HasFlag(PlayerFliedsFlags.CustomProperties))
            {
                this.CustomProperties.WriteToMessage(message);
            }
        }
        /// <summary>
        /// Writes the fields to be sync on an outgoing message.
        /// </summary>
        /// <param name="message">The outgoing message</param>
        /// <param name="forceAllFields">Indicates if all fields must be forced to sync</param>
        internal void WriteSyncMessage(OutgoingMessage message, bool forceAllFields = false)
        {
            if (forceAllFields)
            {
                this.pendingSyncFields = PlayerFliedsFlags.All;
                this.CustomProperties.ForceFullSync();
            }
            else if (this.CustomProperties.NeedSync)
            {
                this.pendingSyncFields |= PlayerFliedsFlags.CustomProperties;
            }

            this.WriteToMessage(message, this.pendingSyncFields);

            this.pendingSyncFields = PlayerFliedsFlags.None;
        }