Latest packet handling, parsing, enums, generators, etc..
This commit is contained in:
@@ -25,4 +25,58 @@ export class SimulatorViewerTimeMessagePacket implements Packet
|
||||
return 44;
|
||||
}
|
||||
|
||||
writeToBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
buf.writeInt32LE(this.TimeInfo['UsecSinceStart'].low, pos);
|
||||
pos += 4;
|
||||
buf.writeInt32LE(this.TimeInfo['UsecSinceStart'].high, pos);
|
||||
pos += 4;
|
||||
buf.writeUInt32LE(this.TimeInfo['SecPerDay'], pos);
|
||||
pos += 4;
|
||||
buf.writeUInt32LE(this.TimeInfo['SecPerYear'], pos);
|
||||
pos += 4;
|
||||
this.TimeInfo['SunDirection'].writeToBuffer(buf, pos, false);
|
||||
pos += 12;
|
||||
buf.writeFloatLE(this.TimeInfo['SunPhase'], pos);
|
||||
pos += 4;
|
||||
this.TimeInfo['SunAngVelocity'].writeToBuffer(buf, pos, false);
|
||||
pos += 12;
|
||||
return pos - startPos;
|
||||
}
|
||||
|
||||
readFromBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
const newObjTimeInfo: {
|
||||
UsecSinceStart: Long,
|
||||
SecPerDay: number,
|
||||
SecPerYear: number,
|
||||
SunDirection: Vector3,
|
||||
SunPhase: number,
|
||||
SunAngVelocity: Vector3
|
||||
} = {
|
||||
UsecSinceStart: Long.ZERO,
|
||||
SecPerDay: 0,
|
||||
SecPerYear: 0,
|
||||
SunDirection: Vector3.getZero(),
|
||||
SunPhase: 0,
|
||||
SunAngVelocity: Vector3.getZero()
|
||||
};
|
||||
newObjTimeInfo['UsecSinceStart'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4));
|
||||
pos += 8;
|
||||
newObjTimeInfo['SecPerDay'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjTimeInfo['SecPerYear'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjTimeInfo['SunDirection'] = new Vector3(buf, pos, false);
|
||||
pos += 12;
|
||||
newObjTimeInfo['SunPhase'] = buf.readFloatLE(pos);
|
||||
pos += 4;
|
||||
newObjTimeInfo['SunAngVelocity'] = new Vector3(buf, pos, false);
|
||||
pos += 12;
|
||||
this.TimeInfo = newObjTimeInfo;
|
||||
return pos - startPos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user