111 lines
3.5 KiB
TypeScript
111 lines
3.5 KiB
TypeScript
// 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 ChatPassMessage implements MessageBase
|
|
{
|
|
name = 'ChatPass';
|
|
messageFlags = MessageFlags.Trusted | MessageFlags.Zerocoded | MessageFlags.FrequencyLow;
|
|
id = Message.ChatPass;
|
|
|
|
ChatData: {
|
|
Channel: number;
|
|
Position: Vector3;
|
|
ID: UUID;
|
|
OwnerID: UUID;
|
|
Name: string;
|
|
SourceType: number;
|
|
Type: number;
|
|
Radius: number;
|
|
SimAccess: number;
|
|
Message: string;
|
|
};
|
|
|
|
getSize(): number
|
|
{
|
|
return (this.ChatData['Name'].length + 1 + this.ChatData['Message'].length + 2) + 55;
|
|
}
|
|
|
|
writeToBuffer(buf: Buffer, pos: number): number
|
|
{
|
|
const startPos = pos;
|
|
buf.writeInt32LE(this.ChatData['Channel'], pos);
|
|
pos += 4;
|
|
this.ChatData['Position'].writeToBuffer(buf, pos, false);
|
|
pos += 12;
|
|
this.ChatData['ID'].writeToBuffer(buf, pos);
|
|
pos += 16;
|
|
this.ChatData['OwnerID'].writeToBuffer(buf, pos);
|
|
pos += 16;
|
|
buf.writeUInt8(this.ChatData['Name'].length, pos++);
|
|
buf.write(this.ChatData['Name'], pos);
|
|
pos += this.ChatData['Name'].length;
|
|
buf.writeUInt8(this.ChatData['SourceType'], pos++);
|
|
buf.writeUInt8(this.ChatData['Type'], pos++);
|
|
buf.writeFloatLE(this.ChatData['Radius'], pos);
|
|
pos += 4;
|
|
buf.writeUInt8(this.ChatData['SimAccess'], pos++);
|
|
buf.writeUInt16LE(this.ChatData['Message'].length, pos);
|
|
pos += 2;
|
|
buf.write(this.ChatData['Message'], pos);
|
|
pos += this.ChatData['Message'].length;
|
|
return pos - startPos;
|
|
}
|
|
|
|
readFromBuffer(buf: Buffer, pos: number): number
|
|
{
|
|
const startPos = pos;
|
|
let varLength = 0;
|
|
const newObjChatData: {
|
|
Channel: number,
|
|
Position: Vector3,
|
|
ID: UUID,
|
|
OwnerID: UUID,
|
|
Name: string,
|
|
SourceType: number,
|
|
Type: number,
|
|
Radius: number,
|
|
SimAccess: number,
|
|
Message: string
|
|
} = {
|
|
Channel: 0,
|
|
Position: Vector3.getZero(),
|
|
ID: UUID.zero(),
|
|
OwnerID: UUID.zero(),
|
|
Name: '',
|
|
SourceType: 0,
|
|
Type: 0,
|
|
Radius: 0,
|
|
SimAccess: 0,
|
|
Message: ''
|
|
};
|
|
newObjChatData['Channel'] = buf.readInt32LE(pos);
|
|
pos += 4;
|
|
newObjChatData['Position'] = new Vector3(buf, pos, false);
|
|
pos += 12;
|
|
newObjChatData['ID'] = new UUID(buf, pos);
|
|
pos += 16;
|
|
newObjChatData['OwnerID'] = new UUID(buf, pos);
|
|
pos += 16;
|
|
varLength = buf.readUInt8(pos++);
|
|
newObjChatData['Name'] = buf.toString('utf8', pos, pos + (varLength - 1));
|
|
pos += varLength;
|
|
newObjChatData['SourceType'] = buf.readUInt8(pos++);
|
|
newObjChatData['Type'] = buf.readUInt8(pos++);
|
|
newObjChatData['Radius'] = buf.readFloatLE(pos);
|
|
pos += 4;
|
|
newObjChatData['SimAccess'] = buf.readUInt8(pos++);
|
|
varLength = buf.readUInt16LE(pos);
|
|
pos += 2;
|
|
newObjChatData['Message'] = buf.toString('utf8', pos, pos + (varLength - 1));
|
|
pos += varLength;
|
|
this.ChatData = newObjChatData;
|
|
return pos - startPos;
|
|
}
|
|
}
|
|
|