Latest packet handling, parsing, enums, generators, etc..

This commit is contained in:
Casper Warden
2017-11-24 17:45:34 +00:00
parent ec300e33ac
commit 261f28698a
496 changed files with 30448 additions and 57 deletions

View File

@@ -23,4 +23,52 @@ export class SetFollowCamPropertiesPacket implements Packet
return ((8) * this.CameraProperty.length) + 17;
}
writeToBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
this.ObjectData['ObjectID'].writeToBuffer(buf, pos);
pos += 16;
const count = this.CameraProperty.length;
buf.writeUInt8(this.CameraProperty.length, pos++);
for (let i = 0; i < count; i++)
{
buf.writeInt32LE(this.CameraProperty[i]['Type'], pos);
pos += 4;
buf.writeFloatLE(this.CameraProperty[i]['Value'], pos);
pos += 4;
}
return pos - startPos;
}
readFromBuffer(buf: Buffer, pos: number): number
{
const startPos = pos;
const newObjObjectData: {
ObjectID: UUID
} = {
ObjectID: UUID.zero()
};
newObjObjectData['ObjectID'] = new UUID(buf, pos);
pos += 16;
this.ObjectData = newObjObjectData;
const count = buf.readUInt8(pos++);
this.CameraProperty = [];
for (let i = 0; i < count; i++)
{
const newObjCameraProperty: {
Type: number,
Value: number
} = {
Type: 0,
Value: 0
};
newObjCameraProperty['Type'] = buf.readInt32LE(pos);
pos += 4;
newObjCameraProperty['Value'] = buf.readFloatLE(pos);
pos += 4;
this.CameraProperty.push(newObjCameraProperty);
}
return pos - startPos;
}
}