Latest packet handling, parsing, enums, generators, etc..
This commit is contained in:
@@ -27,4 +27,64 @@ export class SoundTriggerPacket implements Packet
|
||||
return 88;
|
||||
}
|
||||
|
||||
writeToBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
this.SoundData['SoundID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
this.SoundData['OwnerID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
this.SoundData['ObjectID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
this.SoundData['ParentID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.writeInt32LE(this.SoundData['Handle'].low, pos);
|
||||
pos += 4;
|
||||
buf.writeInt32LE(this.SoundData['Handle'].high, pos);
|
||||
pos += 4;
|
||||
this.SoundData['Position'].writeToBuffer(buf, pos, false);
|
||||
pos += 12;
|
||||
buf.writeFloatLE(this.SoundData['Gain'], pos);
|
||||
pos += 4;
|
||||
return pos - startPos;
|
||||
}
|
||||
|
||||
readFromBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
const newObjSoundData: {
|
||||
SoundID: UUID,
|
||||
OwnerID: UUID,
|
||||
ObjectID: UUID,
|
||||
ParentID: UUID,
|
||||
Handle: Long,
|
||||
Position: Vector3,
|
||||
Gain: number
|
||||
} = {
|
||||
SoundID: UUID.zero(),
|
||||
OwnerID: UUID.zero(),
|
||||
ObjectID: UUID.zero(),
|
||||
ParentID: UUID.zero(),
|
||||
Handle: Long.ZERO,
|
||||
Position: Vector3.getZero(),
|
||||
Gain: 0
|
||||
};
|
||||
newObjSoundData['SoundID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjSoundData['OwnerID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjSoundData['ObjectID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjSoundData['ParentID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjSoundData['Handle'] = new Long(buf.readInt32LE(pos), buf.readInt32LE(pos+4));
|
||||
pos += 8;
|
||||
newObjSoundData['Position'] = new Vector3(buf, pos, false);
|
||||
pos += 12;
|
||||
newObjSoundData['Gain'] = buf.readFloatLE(pos);
|
||||
pos += 4;
|
||||
this.SoundData = newObjSoundData;
|
||||
return pos - startPos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user