Latest packet handling, parsing, enums, generators, etc..
This commit is contained in:
@@ -32,4 +32,88 @@ export class AgentUpdatePacket implements Packet
|
||||
return 114;
|
||||
}
|
||||
|
||||
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;
|
||||
this.AgentData['BodyRotation'].writeToBuffer(buf, pos);
|
||||
pos += 12;
|
||||
this.AgentData['HeadRotation'].writeToBuffer(buf, pos);
|
||||
pos += 12;
|
||||
buf.writeUInt8(this.AgentData['State'], pos++);
|
||||
this.AgentData['CameraCenter'].writeToBuffer(buf, pos, false);
|
||||
pos += 12;
|
||||
this.AgentData['CameraAtAxis'].writeToBuffer(buf, pos, false);
|
||||
pos += 12;
|
||||
this.AgentData['CameraLeftAxis'].writeToBuffer(buf, pos, false);
|
||||
pos += 12;
|
||||
this.AgentData['CameraUpAxis'].writeToBuffer(buf, pos, false);
|
||||
pos += 12;
|
||||
buf.writeFloatLE(this.AgentData['Far'], pos);
|
||||
pos += 4;
|
||||
buf.writeUInt32LE(this.AgentData['ControlFlags'], pos);
|
||||
pos += 4;
|
||||
buf.writeUInt8(this.AgentData['Flags'], pos++);
|
||||
return pos - startPos;
|
||||
}
|
||||
|
||||
readFromBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
const newObjAgentData: {
|
||||
AgentID: UUID,
|
||||
SessionID: UUID,
|
||||
BodyRotation: Quaternion,
|
||||
HeadRotation: Quaternion,
|
||||
State: number,
|
||||
CameraCenter: Vector3,
|
||||
CameraAtAxis: Vector3,
|
||||
CameraLeftAxis: Vector3,
|
||||
CameraUpAxis: Vector3,
|
||||
Far: number,
|
||||
ControlFlags: number,
|
||||
Flags: number
|
||||
} = {
|
||||
AgentID: UUID.zero(),
|
||||
SessionID: UUID.zero(),
|
||||
BodyRotation: Quaternion.getIdentity(),
|
||||
HeadRotation: Quaternion.getIdentity(),
|
||||
State: 0,
|
||||
CameraCenter: Vector3.getZero(),
|
||||
CameraAtAxis: Vector3.getZero(),
|
||||
CameraLeftAxis: Vector3.getZero(),
|
||||
CameraUpAxis: Vector3.getZero(),
|
||||
Far: 0,
|
||||
ControlFlags: 0,
|
||||
Flags: 0
|
||||
};
|
||||
newObjAgentData['AgentID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjAgentData['SessionID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjAgentData['BodyRotation'] = new Quaternion(buf, pos);
|
||||
pos += 12;
|
||||
newObjAgentData['HeadRotation'] = new Quaternion(buf, pos);
|
||||
pos += 12;
|
||||
newObjAgentData['State'] = buf.readUInt8(pos++);
|
||||
newObjAgentData['CameraCenter'] = new Vector3(buf, pos, false);
|
||||
pos += 12;
|
||||
newObjAgentData['CameraAtAxis'] = new Vector3(buf, pos, false);
|
||||
pos += 12;
|
||||
newObjAgentData['CameraLeftAxis'] = new Vector3(buf, pos, false);
|
||||
pos += 12;
|
||||
newObjAgentData['CameraUpAxis'] = new Vector3(buf, pos, false);
|
||||
pos += 12;
|
||||
newObjAgentData['Far'] = buf.readFloatLE(pos);
|
||||
pos += 4;
|
||||
newObjAgentData['ControlFlags'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjAgentData['Flags'] = buf.readUInt8(pos++);
|
||||
this.AgentData = newObjAgentData;
|
||||
return pos - startPos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user