UNPKG

node-insim

Version:

An InSim library for NodeJS with TypeScript support

128 lines (127 loc) 3.93 kB
import { __decorate } from "tslib"; import { float, int, unsigned } from '../decorators'; import { Struct } from '../packets'; /** * OutSim - MOTION SIMULATOR SUPPORT AND TELEMETRY OUTPUT * * The user's car in multiplayer or the viewed car in single player or single player * replay can output data to an external program while in VIEW_DRIVER or VIEW_CUSTOM. * * This can be controlled by 6 lines in the cfg.txt file: * * OutSim Mode 0 : 0 = off / 1 = driving / 2 = driving + replay * OutSim Delay 1 : minimum delay between packets (100ths of a sec) * OutSim IP 0.0.0.0 : IP address to send the UDP packet * OutSim Port 0 : IP port * OutSim ID 0 : if not zero, adds an identifier to the packet * OutSim Opts 0 : see docs\OutSimPack.txt for the available options * * If OutSim Opts is zero, each update sends the following UDP packet. * * NOTE 1) X and Y axes are on the ground, Z is up. * * NOTE 2) Motion simulators can be dangerous. The Live for Speed developers do * not support any motion systems in particular and cannot accept responsibility * for injuries or deaths connected with the use of such machinery. */ export class OutSimPack extends Struct { constructor() { super(...arguments); /** Time in milliseconds (to check order) */ this.Time = 0; /** Angular velocity vector - X axis */ this.AngVelX = 0; /** Angular velocity vector - Y axis */ this.AngVelY = 0; /** Angular velocity vector - Z axis */ this.AngVelZ = 0; /** Anticlockwise from above (Z) */ this.Heading = 0; /** Anticlockwise from above (Z) */ this.Pitch = 0; /** Anticlockwise from above (Z) */ this.Roll = 0; /** Acceleration - X axis */ this.AccelX = 0; /** Acceleration - Y axis */ this.AccelY = 0; /** Acceleration - Z axis */ this.AccelZ = 0; /** Velocity - X axis */ this.VelX = 0; /** Velocity - Y axis */ this.VelY = 0; /** Velocity - Z axis */ this.VelZ = 0; /** Position - X axis (1 m = 65536) */ this.PosX = 0; /** Position - Y axis (1 m = 65536) */ this.PosY = 0; /** Position - Z axis (1 m = 65536) */ this.PosZ = 0; /** Optional - only if OutSim ID is specified */ this.ID = 0; } unpack(buffer) { let outSimData = buffer; if (buffer.length === OutSimPack.MIN_SIZE) { outSimData = new Uint8Array(OutSimPack.MAX_SIZE); outSimData.set(buffer); outSimData.set([0], OutSimPack.MIN_SIZE); } return super.unpack(outSimData); } } OutSimPack.MIN_SIZE = 64; OutSimPack.MAX_SIZE = 68; __decorate([ unsigned() ], OutSimPack.prototype, "Time", void 0); __decorate([ float() ], OutSimPack.prototype, "AngVelX", void 0); __decorate([ float() ], OutSimPack.prototype, "AngVelY", void 0); __decorate([ float() ], OutSimPack.prototype, "AngVelZ", void 0); __decorate([ float() ], OutSimPack.prototype, "Heading", void 0); __decorate([ float() ], OutSimPack.prototype, "Pitch", void 0); __decorate([ float() ], OutSimPack.prototype, "Roll", void 0); __decorate([ float() ], OutSimPack.prototype, "AccelX", void 0); __decorate([ float() ], OutSimPack.prototype, "AccelY", void 0); __decorate([ float() ], OutSimPack.prototype, "AccelZ", void 0); __decorate([ float() ], OutSimPack.prototype, "VelX", void 0); __decorate([ float() ], OutSimPack.prototype, "VelY", void 0); __decorate([ float() ], OutSimPack.prototype, "VelZ", void 0); __decorate([ int() ], OutSimPack.prototype, "PosX", void 0); __decorate([ int() ], OutSimPack.prototype, "PosY", void 0); __decorate([ int() ], OutSimPack.prototype, "PosZ", void 0); __decorate([ int() ], OutSimPack.prototype, "ID", void 0);