UNPKG

node-insim

Version:

An InSim library for NodeJS with TypeScript support

188 lines (187 loc) 6.97 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.OutGaugePack = void 0; var decorators_1 = require("../decorators"); var packets_1 = require("../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. */ var OutGaugePack = /** @class */ (function (_super) { __extends(OutGaugePack, _super); function OutGaugePack() { var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this; /** 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; return _this; } OutGaugePack.prototype.unpack = function (buffer) { var 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.prototype.unpack.call(this, outGaugeData); }; OutGaugePack.MIN_SIZE = 92; OutGaugePack.MAX_SIZE = 96; __decorate([ (0, decorators_1.unsigned)() ], OutGaugePack.prototype, "Time", void 0); __decorate([ (0, decorators_1.carName)() ], OutGaugePack.prototype, "Car", void 0); __decorate([ (0, decorators_1.word)() ], OutGaugePack.prototype, "Flags", void 0); __decorate([ (0, decorators_1.byte)() ], OutGaugePack.prototype, "Gear", void 0); __decorate([ (0, decorators_1.byte)() ], OutGaugePack.prototype, "PLID", void 0); __decorate([ (0, decorators_1.float)() ], OutGaugePack.prototype, "Speed", void 0); __decorate([ (0, decorators_1.float)() ], OutGaugePack.prototype, "RPM", void 0); __decorate([ (0, decorators_1.float)() ], OutGaugePack.prototype, "Turbo", void 0); __decorate([ (0, decorators_1.float)() ], OutGaugePack.prototype, "EngTemp", void 0); __decorate([ (0, decorators_1.float)() ], OutGaugePack.prototype, "Fuel", void 0); __decorate([ (0, decorators_1.float)() ], OutGaugePack.prototype, "OilPressure", void 0); __decorate([ (0, decorators_1.float)() ], OutGaugePack.prototype, "OilTemp", void 0); __decorate([ (0, decorators_1.unsigned)() ], OutGaugePack.prototype, "DashLights", void 0); __decorate([ (0, decorators_1.unsigned)() ], OutGaugePack.prototype, "ShowLights", void 0); __decorate([ (0, decorators_1.float)() ], OutGaugePack.prototype, "Throttle", void 0); __decorate([ (0, decorators_1.float)() ], OutGaugePack.prototype, "Brake", void 0); __decorate([ (0, decorators_1.float)() ], OutGaugePack.prototype, "Clutch", void 0); __decorate([ (0, decorators_1.string)(16) ], OutGaugePack.prototype, "Display1", void 0); __decorate([ (0, decorators_1.string)(16) ], OutGaugePack.prototype, "Display2", void 0); __decorate([ (0, decorators_1.int)() ], OutGaugePack.prototype, "ID", void 0); return OutGaugePack; }(packets_1.Struct)); exports.OutGaugePack = OutGaugePack;