// This file has been automatically generated by writeMessageClasses.js import { UUID } from '../UUID'; import { Vector3 } from '../Vector3'; import * as Long from 'long'; import { Quaternion } from '../Quaternion'; import { MessageFlags } from '../../enums/MessageFlags'; import { MessageBase } from '../MessageBase'; import { Message } from '../../enums/Message'; export class ChildAgentUpdateMessage implements MessageBase { name = 'ChildAgentUpdate'; messageFlags = MessageFlags.Trusted | MessageFlags.Zerocoded | MessageFlags.FrequencyHigh; id = Message.ChildAgentUpdate; AgentData: { RegionHandle: Long; ViewerCircuitCode: number; AgentID: UUID; SessionID: UUID; AgentPos: Vector3; AgentVel: Vector3; Center: Vector3; Size: Vector3; AtAxis: Vector3; LeftAxis: Vector3; UpAxis: Vector3; ChangedGrid: boolean; Far: number; Aspect: number; Throttles: Buffer; LocomotionState: number; HeadRotation: Quaternion; BodyRotation: Quaternion; ControlFlags: number; EnergyLevel: number; GodLevel: number; AlwaysRun: boolean; PreyAgent: UUID; AgentAccess: number; AgentTextures: Buffer; ActiveGroupID: UUID; }; GroupData: { GroupID: UUID; GroupPowers: Long; AcceptNotices: boolean; }[]; AnimationData: { Animation: UUID; ObjectID: UUID; }[]; GranterBlock: { GranterID: UUID; }[]; NVPairData: { NVPairs: Buffer; }[]; VisualParam: { ParamValue: number; }[]; AgentAccess: { AgentLegacyAccess: number; AgentMaxAccess: number; }[]; AgentInfo: { Flags: number; }[]; getSize(): number { return (this.AgentData['Throttles'].length + 1 + this.AgentData['AgentTextures'].length + 2) + ((25) * this.GroupData.length) + ((32) * this.AnimationData.length) + ((16) * this.GranterBlock.length) + this.calculateVarVarSize(this.NVPairData, 'NVPairs', 2) + ((1) * this.VisualParam.length) + ((2) * this.AgentAccess.length) + ((4) * this.AgentInfo.length) + 215; } 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; buf.writeInt32LE(this.AgentData['RegionHandle'].low, pos); pos += 4; buf.writeInt32LE(this.AgentData['RegionHandle'].high, pos); pos += 4; buf.writeUInt32LE(this.AgentData['ViewerCircuitCode'], pos); pos += 4; this.AgentData['AgentID'].writeToBuffer(buf, pos); pos += 16; this.AgentData['SessionID'].writeToBuffer(buf, pos); pos += 16; this.AgentData['AgentPos'].writeToBuffer(buf, pos, false); pos += 12; this.AgentData['AgentVel'].writeToBuffer(buf, pos, false); pos += 12; this.AgentData['Center'].writeToBuffer(buf, pos, false); pos += 12; this.AgentData['Size'].writeToBuffer(buf, pos, false); pos += 12; this.AgentData['AtAxis'].writeToBuffer(buf, pos, false); pos += 12; this.AgentData['LeftAxis'].writeToBuffer(buf, pos, false); pos += 12; this.AgentData['UpAxis'].writeToBuffer(buf, pos, false); pos += 12; buf.writeUInt8((this.AgentData['ChangedGrid']) ? 1 : 0, pos++); buf.writeFloatLE(this.AgentData['Far'], pos); pos += 4; buf.writeFloatLE(this.AgentData['Aspect'], pos); pos += 4; buf.writeUInt8(this.AgentData['Throttles'].length, pos++); this.AgentData['Throttles'].copy(buf, pos); pos += this.AgentData['Throttles'].length; buf.writeUInt32LE(this.AgentData['LocomotionState'], pos); pos += 4; this.AgentData['HeadRotation'].writeToBuffer(buf, pos); pos += 12; this.AgentData['BodyRotation'].writeToBuffer(buf, pos); pos += 12; buf.writeUInt32LE(this.AgentData['ControlFlags'], pos); pos += 4; buf.writeFloatLE(this.AgentData['EnergyLevel'], pos); pos += 4; buf.writeUInt8(this.AgentData['GodLevel'], pos++); buf.writeUInt8((this.AgentData['AlwaysRun']) ? 1 : 0, pos++); this.AgentData['PreyAgent'].writeToBuffer(buf, pos); pos += 16; buf.writeUInt8(this.AgentData['AgentAccess'], pos++); buf.writeUInt16LE(this.AgentData['AgentTextures'].length, pos); pos += 2; this.AgentData['AgentTextures'].copy(buf, pos); pos += this.AgentData['AgentTextures'].length; this.AgentData['ActiveGroupID'].writeToBuffer(buf, pos); pos += 16; let count = this.GroupData.length; buf.writeUInt8(this.GroupData.length, pos++); for (let i = 0; i < count; i++) { this.GroupData[i]['GroupID'].writeToBuffer(buf, pos); pos += 16; buf.writeInt32LE(this.GroupData[i]['GroupPowers'].low, pos); pos += 4; buf.writeInt32LE(this.GroupData[i]['GroupPowers'].high, pos); pos += 4; buf.writeUInt8((this.GroupData[i]['AcceptNotices']) ? 1 : 0, pos++); } count = this.AnimationData.length; buf.writeUInt8(this.AnimationData.length, pos++); for (let i = 0; i < count; i++) { this.AnimationData[i]['Animation'].writeToBuffer(buf, pos); pos += 16; this.AnimationData[i]['ObjectID'].writeToBuffer(buf, pos); pos += 16; } count = this.GranterBlock.length; buf.writeUInt8(this.GranterBlock.length, pos++); for (let i = 0; i < count; i++) { this.GranterBlock[i]['GranterID'].writeToBuffer(buf, pos); pos += 16; } count = this.NVPairData.length; buf.writeUInt8(this.NVPairData.length, pos++); for (let i = 0; i < count; i++) { buf.writeUInt16LE(this.NVPairData[i]['NVPairs'].length, pos); pos += 2; this.NVPairData[i]['NVPairs'].copy(buf, pos); pos += this.NVPairData[i]['NVPairs'].length; } count = this.VisualParam.length; buf.writeUInt8(this.VisualParam.length, pos++); for (let i = 0; i < count; i++) { buf.writeUInt8(this.VisualParam[i]['ParamValue'], pos++); } count = this.AgentAccess.length; buf.writeUInt8(this.AgentAccess.length, pos++); for (let i = 0; i < count; i++) { buf.writeUInt8(this.AgentAccess[i]['AgentLegacyAccess'], pos++); buf.writeUInt8(this.AgentAccess[i]['AgentMaxAccess'], pos++); } count = this.AgentInfo.length; buf.writeUInt8(this.AgentInfo.length, pos++); for (let i = 0; i < count; i++) { buf.writeUInt32LE(this.AgentInfo[i]['Flags'], pos); pos += 4; } return pos - startPos; } // @ts-ignore readFromBuffer(buf: Buffer, pos: number): number { const startPos = pos; let varLength = 0; const newObjAgentData: { RegionHandle: Long, ViewerCircuitCode: number, AgentID: UUID, SessionID: UUID, AgentPos: Vector3, AgentVel: Vector3, Center: Vector3, Size: Vector3, AtAxis: Vector3, LeftAxis: Vector3, UpAxis: Vector3, ChangedGrid: boolean, Far: number, Aspect: number, Throttles: Buffer, LocomotionState: number, HeadRotation: Quaternion, BodyRotation: Quaternion, ControlFlags: number, EnergyLevel: number, GodLevel: number, AlwaysRun: boolean, PreyAgent: UUID, AgentAccess: number, AgentTextures: Buffer, ActiveGroupID: UUID } = { RegionHandle: Long.ZERO, ViewerCircuitCode: 0, AgentID: UUID.zero(), SessionID: UUID.zero(), AgentPos: Vector3.getZero(), AgentVel: Vector3.getZero(), Center: Vector3.getZero(), Size: Vector3.getZero(), AtAxis: Vector3.getZero(), LeftAxis: Vector3.getZero(), UpAxis: Vector3.getZero(), ChangedGrid: false, Far: 0, Aspect: 0, Throttles: Buffer.allocUnsafe(0), LocomotionState: 0, HeadRotation: Quaternion.getIdentity(), BodyRotation: Quaternion.getIdentity(), ControlFlags: 0, EnergyLevel: 0, GodLevel: 0, AlwaysRun: false, PreyAgent: UUID.zero(), AgentAccess: 0, AgentTextures: Buffer.allocUnsafe(0), ActiveGroupID: UUID.zero() }; newObjAgentData['RegionHandle'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos + 4)); pos += 8; newObjAgentData['ViewerCircuitCode'] = buf.readUInt32LE(pos); pos += 4; newObjAgentData['AgentID'] = new UUID(buf, pos); pos += 16; newObjAgentData['SessionID'] = new UUID(buf, pos); pos += 16; newObjAgentData['AgentPos'] = new Vector3(buf, pos, false); pos += 12; newObjAgentData['AgentVel'] = new Vector3(buf, pos, false); pos += 12; newObjAgentData['Center'] = new Vector3(buf, pos, false); pos += 12; newObjAgentData['Size'] = new Vector3(buf, pos, false); pos += 12; newObjAgentData['AtAxis'] = new Vector3(buf, pos, false); pos += 12; newObjAgentData['LeftAxis'] = new Vector3(buf, pos, false); pos += 12; newObjAgentData['UpAxis'] = new Vector3(buf, pos, false); pos += 12; newObjAgentData['ChangedGrid'] = (buf.readUInt8(pos++) === 1); newObjAgentData['Far'] = buf.readFloatLE(pos); pos += 4; newObjAgentData['Aspect'] = buf.readFloatLE(pos); pos += 4; varLength = buf.readUInt8(pos++); newObjAgentData['Throttles'] = buf.slice(pos, pos + varLength); pos += varLength; newObjAgentData['LocomotionState'] = buf.readUInt32LE(pos); pos += 4; newObjAgentData['HeadRotation'] = new Quaternion(buf, pos); pos += 12; newObjAgentData['BodyRotation'] = new Quaternion(buf, pos); pos += 12; newObjAgentData['ControlFlags'] = buf.readUInt32LE(pos); pos += 4; newObjAgentData['EnergyLevel'] = buf.readFloatLE(pos); pos += 4; newObjAgentData['GodLevel'] = buf.readUInt8(pos++); newObjAgentData['AlwaysRun'] = (buf.readUInt8(pos++) === 1); newObjAgentData['PreyAgent'] = new UUID(buf, pos); pos += 16; newObjAgentData['AgentAccess'] = buf.readUInt8(pos++); varLength = buf.readUInt16LE(pos); pos += 2; newObjAgentData['AgentTextures'] = buf.slice(pos, pos + varLength); pos += varLength; newObjAgentData['ActiveGroupID'] = new UUID(buf, pos); pos += 16; this.AgentData = newObjAgentData; if (pos >= buf.length) { return pos - startPos; } let count = buf.readUInt8(pos++); this.GroupData = []; for (let i = 0; i < count; i++) { const newObjGroupData: { GroupID: UUID, GroupPowers: Long, AcceptNotices: boolean } = { GroupID: UUID.zero(), GroupPowers: Long.ZERO, AcceptNotices: false }; newObjGroupData['GroupID'] = new UUID(buf, pos); pos += 16; newObjGroupData['GroupPowers'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos + 4)); pos += 8; newObjGroupData['AcceptNotices'] = (buf.readUInt8(pos++) === 1); this.GroupData.push(newObjGroupData); } if (pos >= buf.length) { return pos - startPos; } count = buf.readUInt8(pos++); this.AnimationData = []; for (let i = 0; i < count; i++) { const newObjAnimationData: { Animation: UUID, ObjectID: UUID } = { Animation: UUID.zero(), ObjectID: UUID.zero() }; newObjAnimationData['Animation'] = new UUID(buf, pos); pos += 16; newObjAnimationData['ObjectID'] = new UUID(buf, pos); pos += 16; this.AnimationData.push(newObjAnimationData); } if (pos >= buf.length) { return pos - startPos; } count = buf.readUInt8(pos++); this.GranterBlock = []; for (let i = 0; i < count; i++) { const newObjGranterBlock: { GranterID: UUID } = { GranterID: UUID.zero() }; newObjGranterBlock['GranterID'] = new UUID(buf, pos); pos += 16; this.GranterBlock.push(newObjGranterBlock); } if (pos >= buf.length) { return pos - startPos; } count = buf.readUInt8(pos++); this.NVPairData = []; for (let i = 0; i < count; i++) { const newObjNVPairData: { NVPairs: Buffer } = { NVPairs: Buffer.allocUnsafe(0) }; varLength = buf.readUInt16LE(pos); pos += 2; newObjNVPairData['NVPairs'] = buf.slice(pos, pos + varLength); pos += varLength; this.NVPairData.push(newObjNVPairData); } if (pos >= buf.length) { return pos - startPos; } count = buf.readUInt8(pos++); this.VisualParam = []; for (let i = 0; i < count; i++) { const newObjVisualParam: { ParamValue: number } = { ParamValue: 0 }; newObjVisualParam['ParamValue'] = buf.readUInt8(pos++); this.VisualParam.push(newObjVisualParam); } if (pos >= buf.length) { return pos - startPos; } count = buf.readUInt8(pos++); this.AgentAccess = []; for (let i = 0; i < count; i++) { const newObjAgentAccess: { AgentLegacyAccess: number, AgentMaxAccess: number } = { AgentLegacyAccess: 0, AgentMaxAccess: 0 }; newObjAgentAccess['AgentLegacyAccess'] = buf.readUInt8(pos++); newObjAgentAccess['AgentMaxAccess'] = buf.readUInt8(pos++); this.AgentAccess.push(newObjAgentAccess); } if (pos >= buf.length) { return pos - startPos; } count = buf.readUInt8(pos++); this.AgentInfo = []; for (let i = 0; i < count; i++) { const newObjAgentInfo: { Flags: number } = { Flags: 0 }; newObjAgentInfo['Flags'] = buf.readUInt32LE(pos); pos += 4; this.AgentInfo.push(newObjAgentInfo); } return pos - startPos; } }