Esempio n. 1
0
        /// <inheritdoc/>
        public void ShowLetter(LetterBody letter)
        {
            var letterIndex = this.player.SelectedCharacter.Letters.IndexOf(letter.Header);
            var len         = (ushort)(Encoding.UTF8.GetByteCount(letter.Message) + 28);

            using (var writer = this.connection.StartSafeWrite(0xC4, len))
            {
                var result = writer.Span;
                result[3] = 0xC7;
                result[4] = ((ushort)letterIndex).GetLowByte();
                result[5] = ((ushort)letterIndex).GetHighByte();
                result[6] = ((ushort)(len - 28)).GetLowByte();
                result[7] = ((ushort)(len - 28)).GetHighByte();
                this.appearanceSerializer.WriteAppearanceData(result.Slice(8, this.appearanceSerializer.NeededSpace), letter.SenderAppearance, false);
                result[8 + this.appearanceSerializer.NeededSpace] = letter.Rotation;
                result[9 + this.appearanceSerializer.NeededSpace] = letter.Animation;
                result.Slice(28).WriteString(letter.Message, Encoding.UTF8);
                writer.Commit();
            }
        }
Esempio n. 2
0
        /// <inheritdoc/>
        public void ShowLetter(LetterBody letter)
        {
            var letterIndex = this.player.SelectedCharacter.Letters.IndexOf(letter.Header);
            var len         = (ushort)(Encoding.UTF8.GetByteCount(letter.Message) + 28);
            var result      = new byte[len];

            result[0] = 0xC4;
            result[1] = len.GetHighByte();
            result[2] = len.GetLowByte();
            result[3] = 0xC7;
            result[4] = ((ushort)letterIndex).GetLowByte();
            result[5] = ((ushort)letterIndex).GetHighByte();
            result[6] = ((ushort)(len - 28)).GetLowByte();
            result[7] = ((ushort)(len - 28)).GetHighByte();
            var appearanceBytes = this.appearanceSerializer.GetAppearanceData(letter.SenderAppearance);

            Buffer.BlockCopy(appearanceBytes, 0, result, 8, appearanceBytes.Length);
            result[8 + appearanceBytes.Length] = letter.Rotation; // TODO: check if the index is correct
            result[9 + appearanceBytes.Length] = letter.Animation;
            Buffer.BlockCopy(Encoding.UTF8.GetBytes(letter.Message), 0, result, 28, Encoding.UTF8.GetByteCount(letter.Message));

            this.connection.Send(result);
        }