// This file has been automatically generated by writeMessageClasses.js import { UUID } from '../UUID'; import { MessageFlags } from '../../enums/MessageFlags'; import { MessageBase } from '../MessageBase'; import { Message } from '../../enums/Message'; export class AgentAnimationMessage implements MessageBase { name = 'AgentAnimation'; messageFlags = MessageFlags.FrequencyHigh; id = Message.AgentAnimation; AgentData: { AgentID: UUID; SessionID: UUID; }; AnimationList: { AnimID: UUID; StartAnim: boolean; }[]; PhysicalAvatarEventList: { TypeData: Buffer; }[]; getSize(): number { return ((17) * this.AnimationList.length) + this.calculateVarVarSize(this.PhysicalAvatarEventList, 'TypeData', 1) + 34; } calculateVarVarSize(block: {[key: string]: any}[], paramName: string, extraPerVar: number): number { let size = 0; for (const bl of block) { size += bl[paramName].length + extraPerVar; } return size; } // @ts-ignore writeToBuffer(buf: Buffer, pos: number): number { const startPos = pos; this.AgentData['AgentID'].writeToBuffer(buf, pos); pos += 16; this.AgentData['SessionID'].writeToBuffer(buf, pos); pos += 16; let count = this.AnimationList.length; buf.writeUInt8(this.AnimationList.length, pos++); for (let i = 0; i < count; i++) { this.AnimationList[i]['AnimID'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8((this.AnimationList[i]['StartAnim']) ? 1 : 0, pos++); } count = this.PhysicalAvatarEventList.length; buf.writeUInt8(this.PhysicalAvatarEventList.length, pos++); for (let i = 0; i < count; i++) { buf.writeUInt8(this.PhysicalAvatarEventList[i]['TypeData'].length, pos++); this.PhysicalAvatarEventList[i]['TypeData'].copy(buf, pos); pos += this.PhysicalAvatarEventList[i]['TypeData'].length; } return pos - startPos; } // @ts-ignore readFromBuffer(buf: Buffer, pos: number): number { const startPos = pos; let varLength = 0; const newObjAgentData: { AgentID: UUID, SessionID: UUID } = { AgentID: UUID.zero(), SessionID: UUID.zero() }; newObjAgentData['AgentID'] = new UUID(buf, pos); pos += 16; newObjAgentData['SessionID'] = new UUID(buf, pos); pos += 16; this.AgentData = newObjAgentData; if (pos >= buf.length) { return pos - startPos; } let count = buf.readUInt8(pos++); this.AnimationList = []; for (let i = 0; i < count; i++) { const newObjAnimationList: { AnimID: UUID, StartAnim: boolean } = { AnimID: UUID.zero(), StartAnim: false }; newObjAnimationList['AnimID'] = new UUID(buf, pos); pos += 16; newObjAnimationList['StartAnim'] = (buf.readUInt8(pos++) === 1); this.AnimationList.push(newObjAnimationList); } if (pos >= buf.length) { return pos - startPos; } count = buf.readUInt8(pos++); this.PhysicalAvatarEventList = []; for (let i = 0; i < count; i++) { const newObjPhysicalAvatarEventList: { TypeData: Buffer } = { TypeData: Buffer.allocUnsafe(0) }; varLength = buf.readUInt8(pos++); newObjPhysicalAvatarEventList['TypeData'] = buf.slice(pos, pos + varLength); pos += varLength; this.PhysicalAvatarEventList.push(newObjPhysicalAvatarEventList); } return pos - startPos; } }