// This file has been automatically generated by writeMessageClasses.js import { UUID } from '../UUID'; import { Vector3 } from '../Vector3'; import { MessageFlags } from '../../enums/MessageFlags'; import { MessageBase } from '../MessageBase'; import { Message } from '../../enums/Message'; export class ChatFromSimulatorMessage implements MessageBase { name = 'ChatFromSimulator'; messageFlags = MessageFlags.Trusted | MessageFlags.FrequencyLow; id = Message.ChatFromSimulator; ChatData: { FromName: Buffer; SourceID: UUID; OwnerID: UUID; SourceType: number; ChatType: number; Audible: number; Position: Vector3; Message: Buffer; }; getSize(): number { return (this.ChatData['FromName'].length + 1 + this.ChatData['Message'].length + 2) + 47; } // @ts-ignore writeToBuffer(buf: Buffer, pos: number): number { const startPos = pos; buf.writeUInt8(this.ChatData['FromName'].length, pos++); this.ChatData['FromName'].copy(buf, pos); pos += this.ChatData['FromName'].length; this.ChatData['SourceID'].writeToBuffer(buf, pos); pos += 16; this.ChatData['OwnerID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.ChatData['SourceType'], pos++); buf.writeUInt8(this.ChatData['ChatType'], pos++); buf.writeUInt8(this.ChatData['Audible'], pos++); this.ChatData['Position'].writeToBuffer(buf, pos, false); pos += 12; buf.writeUInt16LE(this.ChatData['Message'].length, pos); pos += 2; this.ChatData['Message'].copy(buf, pos); pos += this.ChatData['Message'].length; return pos - startPos; } // @ts-ignore readFromBuffer(buf: Buffer, pos: number): number { const startPos = pos; let varLength = 0; const newObjChatData: { FromName: Buffer, SourceID: UUID, OwnerID: UUID, SourceType: number, ChatType: number, Audible: number, Position: Vector3, Message: Buffer } = { FromName: Buffer.allocUnsafe(0), SourceID: UUID.zero(), OwnerID: UUID.zero(), SourceType: 0, ChatType: 0, Audible: 0, Position: Vector3.getZero(), Message: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); newObjChatData['FromName'] = buf.slice(pos, pos + varLength); pos += varLength; newObjChatData['SourceID'] = new UUID(buf, pos); pos += 16; newObjChatData['OwnerID'] = new UUID(buf, pos); pos += 16; newObjChatData['SourceType'] = buf.readUInt8(pos++); newObjChatData['ChatType'] = buf.readUInt8(pos++); newObjChatData['Audible'] = buf.readUInt8(pos++); newObjChatData['Position'] = new Vector3(buf, pos, false); pos += 12; varLength = buf.readUInt16LE(pos); pos += 2; newObjChatData['Message'] = buf.slice(pos, pos + varLength); pos += varLength; this.ChatData = newObjChatData; return pos - startPos; } }