UNPKG

node-insim

Version:

An InSim library for NodeJS with TypeScript support

136 lines (135 loc) 3.82 kB
import { __decorate } from "tslib"; import { byte, carName, float, int, string, unsigned, word, } from '../decorators'; import { Struct } from '../packets'; /** * OutGauge - EXTERNAL DASHBOARD SUPPORT * * The user's car in multiplayer or the viewed car in single player or * single player replay can output information to a dashboard system * while viewed from an internal view. * * This can be controlled by 5 lines in the cfg.txt file: * * - OutGauge Mode 0 : 0-off 1-driving 2-driving+replay * - OutGauge Delay 1 : minimum delay between packets (100ths of a sec) * - OutGauge IP 0.0.0.0 : IP address to send the UDP packet * - OutGauge Port 0 : IP port * - OutGauge ID 0 : if not zero, adds an identifier to the packet * * Each update sends the following UDP packet. */ export class OutGaugePack extends Struct { constructor() { super(...arguments); /** Time in milliseconds (to check order) */ this.Time = 0; /** Car name */ this.Car = ''; this.Flags = 0; /** Reverse: 0, Neutral: 1, First: 2,... */ this.Gear = 0; /** Unique ID of viewed player (0 = none) */ this.PLID = 0; /** m/s */ this.Speed = 0; /** RPM */ this.RPM = 0; /** bar */ this.Turbo = 0; /** C */ this.EngTemp = 0; /** 0 to 1 */ this.Fuel = 0; /** bar */ this.OilPressure = 0; /** C */ this.OilTemp = 0; /** Dash lights available */ this.DashLights = 0; /** Dash lights currently switched on */ this.ShowLights = 0; /** 0 to 1 */ this.Throttle = 0; /** 0 to 1 */ this.Brake = 0; /** 0 to 1 */ this.Clutch = 0; /** Usually Fuel */ this.Display1 = ''; /** Usually Settings */ this.Display2 = ''; /** Optional - only if OutGauge ID is specified */ this.ID = 0; } unpack(buffer) { let outGaugeData = buffer; if (buffer.length === OutGaugePack.MIN_SIZE) { outGaugeData = new Uint8Array(OutGaugePack.MAX_SIZE); outGaugeData.set(buffer); outGaugeData.set([0], OutGaugePack.MIN_SIZE); } return super.unpack(outGaugeData); } } OutGaugePack.MIN_SIZE = 92; OutGaugePack.MAX_SIZE = 96; __decorate([ unsigned() ], OutGaugePack.prototype, "Time", void 0); __decorate([ carName() ], OutGaugePack.prototype, "Car", void 0); __decorate([ word() ], OutGaugePack.prototype, "Flags", void 0); __decorate([ byte() ], OutGaugePack.prototype, "Gear", void 0); __decorate([ byte() ], OutGaugePack.prototype, "PLID", void 0); __decorate([ float() ], OutGaugePack.prototype, "Speed", void 0); __decorate([ float() ], OutGaugePack.prototype, "RPM", void 0); __decorate([ float() ], OutGaugePack.prototype, "Turbo", void 0); __decorate([ float() ], OutGaugePack.prototype, "EngTemp", void 0); __decorate([ float() ], OutGaugePack.prototype, "Fuel", void 0); __decorate([ float() ], OutGaugePack.prototype, "OilPressure", void 0); __decorate([ float() ], OutGaugePack.prototype, "OilTemp", void 0); __decorate([ unsigned() ], OutGaugePack.prototype, "DashLights", void 0); __decorate([ unsigned() ], OutGaugePack.prototype, "ShowLights", void 0); __decorate([ float() ], OutGaugePack.prototype, "Throttle", void 0); __decorate([ float() ], OutGaugePack.prototype, "Brake", void 0); __decorate([ float() ], OutGaugePack.prototype, "Clutch", void 0); __decorate([ string(16) ], OutGaugePack.prototype, "Display1", void 0); __decorate([ string(16) ], OutGaugePack.prototype, "Display2", void 0); __decorate([ int() ], OutGaugePack.prototype, "ID", void 0);