Files
node-metaverse/lib/classes/messages/ObjectFlagUpdate.ts

134 lines
4.5 KiB
TypeScript
Raw Normal View History

2017-11-26 01:14:02 +00:00
// This file has been automatically generated by writeMessageClasses.js
import { UUID } from '../UUID';
import { MessageFlags } from '../../enums/MessageFlags';
import { MessageBase } from '../MessageBase';
import { Message } from '../../enums/Message';
2017-11-26 01:14:02 +00:00
export class ObjectFlagUpdateMessage implements MessageBase
{
name = 'ObjectFlagUpdate';
messageFlags = MessageFlags.Zerocoded | MessageFlags.FrequencyLow;
id = Message.ObjectFlagUpdate;
AgentData: {
AgentID: UUID;
SessionID: UUID;
ObjectLocalID: number;
UsePhysics: boolean;
IsTemporary: boolean;
IsPhantom: boolean;
CastsShadows: boolean;
};
ExtraPhysics: {
PhysicsShapeType: number;
Density: number;
Friction: number;
Restitution: number;
GravityMultiplier: number;
}[];
getSize(): number
{
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;
let varLength = 0;
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;
if (pos >= buf.length)
{
return pos - startPos;
}
2017-11-26 01:14:02 +00:00
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;
}
}