Latest packet handling, parsing, enums, generators, etc..
This commit is contained in:
@@ -39,4 +39,92 @@ export class AvatarAnimationPacket implements Packet
|
||||
return size;
|
||||
}
|
||||
|
||||
writeToBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
this.Sender['ID'].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.writeInt32LE(this.AnimationList[i]['AnimSequenceID'], pos);
|
||||
pos += 4;
|
||||
}
|
||||
count = this.AnimationSourceList.length;
|
||||
buf.writeUInt8(this.AnimationSourceList.length, pos++);
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
this.AnimationSourceList[i]['ObjectID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
}
|
||||
count = this.PhysicalAvatarEventList.length;
|
||||
buf.writeUInt8(this.PhysicalAvatarEventList.length, pos++);
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
buf.write(this.PhysicalAvatarEventList[i]['TypeData'], pos);
|
||||
pos += this.PhysicalAvatarEventList[i]['TypeData'].length;
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
|
||||
readFromBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
const newObjSender: {
|
||||
ID: UUID
|
||||
} = {
|
||||
ID: UUID.zero()
|
||||
};
|
||||
newObjSender['ID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
this.Sender = newObjSender;
|
||||
let count = buf.readUInt8(pos++);
|
||||
this.AnimationList = [];
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
const newObjAnimationList: {
|
||||
AnimID: UUID,
|
||||
AnimSequenceID: number
|
||||
} = {
|
||||
AnimID: UUID.zero(),
|
||||
AnimSequenceID: 0
|
||||
};
|
||||
newObjAnimationList['AnimID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjAnimationList['AnimSequenceID'] = buf.readInt32LE(pos);
|
||||
pos += 4;
|
||||
this.AnimationList.push(newObjAnimationList);
|
||||
}
|
||||
count = buf.readUInt8(pos++);
|
||||
this.AnimationSourceList = [];
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
const newObjAnimationSourceList: {
|
||||
ObjectID: UUID
|
||||
} = {
|
||||
ObjectID: UUID.zero()
|
||||
};
|
||||
newObjAnimationSourceList['ObjectID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
this.AnimationSourceList.push(newObjAnimationSourceList);
|
||||
}
|
||||
count = buf.readUInt8(pos++);
|
||||
this.PhysicalAvatarEventList = [];
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
const newObjPhysicalAvatarEventList: {
|
||||
TypeData: string
|
||||
} = {
|
||||
TypeData: ''
|
||||
};
|
||||
newObjPhysicalAvatarEventList['TypeData'] = buf.toString('utf8', pos, length);
|
||||
pos += length;
|
||||
this.PhysicalAvatarEventList.push(newObjPhysicalAvatarEventList);
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user