Files
node-metaverse/lib/classes/messages/AgentFOV.ts
2017-11-26 01:14:02 +00:00

81 lines
2.2 KiB
TypeScript

// 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 AgentFOVMessage implements MessageBase
{
name = 'AgentFOV';
messageFlags = MessageFlags.FrequencyLow;
id = Message.AgentFOV;
AgentData: {
AgentID: UUID;
SessionID: UUID;
CircuitCode: number;
};
FOVBlock: {
GenCounter: number;
VerticalAngle: number;
};
getSize(): number
{
return 44;
}
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;
buf.writeUInt32LE(this.AgentData['CircuitCode'], pos);
pos += 4;
buf.writeUInt32LE(this.FOVBlock['GenCounter'], pos);
pos += 4;
buf.writeFloatLE(this.FOVBlock['VerticalAngle'], pos);
pos += 4;
return pos - startPos;
}
readFromBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
let varLength = 0;
const newObjAgentData: {
AgentID: UUID,
SessionID: UUID,
CircuitCode: number
} = {
AgentID: UUID.zero(),
SessionID: UUID.zero(),
CircuitCode: 0
};
newObjAgentData['AgentID'] = new UUID(buf, pos);
pos += 16;
newObjAgentData['SessionID'] = new UUID(buf, pos);
pos += 16;
newObjAgentData['CircuitCode'] = buf.readUInt32LE(pos);
pos += 4;
this.AgentData = newObjAgentData;
const newObjFOVBlock: {
GenCounter: number,
VerticalAngle: number
} = {
GenCounter: 0,
VerticalAngle: 0
};
newObjFOVBlock['GenCounter'] = buf.readUInt32LE(pos);
pos += 4;
newObjFOVBlock['VerticalAngle'] = buf.readFloatLE(pos);
pos += 4;
this.FOVBlock = newObjFOVBlock;
return pos - startPos;
}
}