Latest packet handling, parsing, enums, generators, etc..
This commit is contained in:
@@ -32,4 +32,96 @@ export class ObjectFlagUpdatePacket implements Packet
|
||||
return ((17) * this.ExtraPhysics.length) + 41;
|
||||
}
|
||||
|
||||
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;
|
||||
buf.writeUInt32LE(this.AgentData['ObjectLocalID'], pos);
|
||||
pos += 4;
|
||||
buf.writeUInt8((this.AgentData['UsePhysics']) ? 1 : 0, pos++);
|
||||
buf.writeUInt8((this.AgentData['IsTemporary']) ? 1 : 0, pos++);
|
||||
buf.writeUInt8((this.AgentData['IsPhantom']) ? 1 : 0, pos++);
|
||||
buf.writeUInt8((this.AgentData['CastsShadows']) ? 1 : 0, pos++);
|
||||
const count = this.ExtraPhysics.length;
|
||||
buf.writeUInt8(this.ExtraPhysics.length, pos++);
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
buf.writeUInt8(this.ExtraPhysics[i]['PhysicsShapeType'], pos++);
|
||||
buf.writeFloatLE(this.ExtraPhysics[i]['Density'], pos);
|
||||
pos += 4;
|
||||
buf.writeFloatLE(this.ExtraPhysics[i]['Friction'], pos);
|
||||
pos += 4;
|
||||
buf.writeFloatLE(this.ExtraPhysics[i]['Restitution'], pos);
|
||||
pos += 4;
|
||||
buf.writeFloatLE(this.ExtraPhysics[i]['GravityMultiplier'], pos);
|
||||
pos += 4;
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
|
||||
readFromBuffer(buf: Buffer, pos: number): number
|
||||
{
|
||||
const startPos = pos;
|
||||
const newObjAgentData: {
|
||||
AgentID: UUID,
|
||||
SessionID: UUID,
|
||||
ObjectLocalID: number,
|
||||
UsePhysics: boolean,
|
||||
IsTemporary: boolean,
|
||||
IsPhantom: boolean,
|
||||
CastsShadows: boolean
|
||||
} = {
|
||||
AgentID: UUID.zero(),
|
||||
SessionID: UUID.zero(),
|
||||
ObjectLocalID: 0,
|
||||
UsePhysics: false,
|
||||
IsTemporary: false,
|
||||
IsPhantom: false,
|
||||
CastsShadows: false
|
||||
};
|
||||
newObjAgentData['AgentID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjAgentData['SessionID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
newObjAgentData['ObjectLocalID'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
newObjAgentData['UsePhysics'] = (buf.readUInt8(pos++) === 1);
|
||||
newObjAgentData['IsTemporary'] = (buf.readUInt8(pos++) === 1);
|
||||
newObjAgentData['IsPhantom'] = (buf.readUInt8(pos++) === 1);
|
||||
newObjAgentData['CastsShadows'] = (buf.readUInt8(pos++) === 1);
|
||||
this.AgentData = newObjAgentData;
|
||||
const count = buf.readUInt8(pos++);
|
||||
this.ExtraPhysics = [];
|
||||
for (let i = 0; i < count; i++)
|
||||
{
|
||||
const newObjExtraPhysics: {
|
||||
PhysicsShapeType: number,
|
||||
Density: number,
|
||||
Friction: number,
|
||||
Restitution: number,
|
||||
GravityMultiplier: number
|
||||
} = {
|
||||
PhysicsShapeType: 0,
|
||||
Density: 0,
|
||||
Friction: 0,
|
||||
Restitution: 0,
|
||||
GravityMultiplier: 0
|
||||
};
|
||||
newObjExtraPhysics['PhysicsShapeType'] = buf.readUInt8(pos++);
|
||||
newObjExtraPhysics['Density'] = buf.readFloatLE(pos);
|
||||
pos += 4;
|
||||
newObjExtraPhysics['Friction'] = buf.readFloatLE(pos);
|
||||
pos += 4;
|
||||
newObjExtraPhysics['Restitution'] = buf.readFloatLE(pos);
|
||||
pos += 4;
|
||||
newObjExtraPhysics['GravityMultiplier'] = buf.readFloatLE(pos);
|
||||
pos += 4;
|
||||
this.ExtraPhysics.push(newObjExtraPhysics);
|
||||
}
|
||||
return pos - startPos;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user