UNPKG

node-insim

Version:

An InSim library for NodeJS with TypeScript support

178 lines (177 loc) 6.78 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.ServerStatus = exports.RaceState = exports.IS_STA = void 0; var decorators_1 = require("../decorators"); var base_1 = require("./base"); var enums_1 = require("./enums"); /** * STAte * * LFS will send an {@link IS_STA} any time the info in it changes. * * To request an IS_STA at any time, send an {@link IS_TINY} * with {@link IS_TINY.SubT} of {@link TinyType.TINY_SST}. */ var IS_STA = /** @class */ (function (_super) { __extends(IS_STA, _super); function IS_STA() { var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this; _this.Size = 28; _this.Type = enums_1.PacketType.ISP_STA; /** ReqI if replying to a request packet */ _this.ReqI = 0; _this.Zero = 0; /** 4-byte float - 1.0 is normal speed */ _this.ReplaySpeed = 0; /** ISS state flags */ _this.Flags = 0; /** Which type of camera is selected (which is still selected * even if LFS is actually in SHIFT+U mode) */ _this.InGameCam = enums_1.ViewIdentifier.VIEW_FOLLOW; /** Unique ID of viewed player (0 = none) */ _this.ViewPLID = 0; /** Number of players in race */ _this.NumP = 0; /** Number of connections including host */ _this.NumConns = 0; /** Number finished or qualified */ _this.NumFinished = 0; /** 0 = no race / 1 = race / 2 = qualifying */ _this.RaceInProg = 0; /** Qualifying length in minutes */ _this.QualMins = 0; /** * RaceLaps (rl): (various meanings depending on range) * * 0 : practice * 1-99 : number of laps... laps = rl * 100-190 : 100 to 1000 laps... laps = (rl - 100) * 10 + 100 * 191-238 : 1 to 48 hours... hours = rl - 190 */ _this.RaceLaps = 0; _this.Sp2 = 0; /** 0 = unknown / 1 = success / > 1 = fail */ _this.ServerStatus = 0; /** Short name for track e.g. FE2R */ _this.Track = ''; _this.Weather = 0; _this.Wind = 0; return _this; } __decorate([ (0, decorators_1.byte)() ], IS_STA.prototype, "Size", void 0); __decorate([ (0, decorators_1.byte)() ], IS_STA.prototype, "Type", void 0); __decorate([ (0, decorators_1.byte)() ], IS_STA.prototype, "ReqI", void 0); __decorate([ (0, decorators_1.byte)() ], IS_STA.prototype, "Zero", void 0); __decorate([ (0, decorators_1.float)() ], IS_STA.prototype, "ReplaySpeed", void 0); __decorate([ (0, decorators_1.word)() ], IS_STA.prototype, "Flags", void 0); __decorate([ (0, decorators_1.byte)() ], IS_STA.prototype, "InGameCam", void 0); __decorate([ (0, decorators_1.byte)() ], IS_STA.prototype, "ViewPLID", void 0); __decorate([ (0, decorators_1.byte)() ], IS_STA.prototype, "NumP", void 0); __decorate([ (0, decorators_1.byte)() ], IS_STA.prototype, "NumConns", void 0); __decorate([ (0, decorators_1.byte)() ], IS_STA.prototype, "NumFinished", void 0); __decorate([ (0, decorators_1.byte)() ], IS_STA.prototype, "RaceInProg", void 0); __decorate([ (0, decorators_1.byte)() ], IS_STA.prototype, "QualMins", void 0); __decorate([ (0, decorators_1.byte)() ], IS_STA.prototype, "RaceLaps", void 0); __decorate([ (0, decorators_1.byte)() ], IS_STA.prototype, "Sp2", void 0); __decorate([ (0, decorators_1.byte)() ], IS_STA.prototype, "ServerStatus", void 0); __decorate([ (0, decorators_1.stringNull)(6) ], IS_STA.prototype, "Track", void 0); __decorate([ (0, decorators_1.byte)() ], IS_STA.prototype, "Weather", void 0); __decorate([ (0, decorators_1.byte)() ], IS_STA.prototype, "Wind", void 0); return IS_STA; }(base_1.Packet)); exports.IS_STA = IS_STA; var RaceState; (function (RaceState) { RaceState[RaceState["NO_RACE"] = 0] = "NO_RACE"; RaceState[RaceState["RACE"] = 1] = "RACE"; RaceState[RaceState["QUALIFYING"] = 2] = "QUALIFYING"; })(RaceState || (exports.RaceState = RaceState = {})); var ServerStatus; (function (ServerStatus) { ServerStatus[ServerStatus["UNKNOWN"] = 0] = "UNKNOWN"; ServerStatus[ServerStatus["SUCCESS"] = 1] = "SUCCESS"; })(ServerStatus || (exports.ServerStatus = ServerStatus = {}));