UNPKG

node-insim

Version:

An InSim library for NodeJS with TypeScript support

124 lines (123 loc) 5.04 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.HLVCViolation = exports.IS_HLV = void 0; var decorators_1 = require("../decorators"); var lfspack_1 = require("../lfspack"); var base_1 = require("./base"); var enums_1 = require("./enums"); var structs_1 = require("./structs"); /** * Hot Lap Validity - off track / hit wall / speeding in pits / out of bounds * * Set the {@link ISF_HLV} flag in the {@link IS_ISI} to receive reports of incidents that would violate HLVC. */ var IS_HLV = /** @class */ (function (_super) { __extends(IS_HLV, _super); function IS_HLV() { var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this; _this.Size = 16; _this.Type = enums_1.PacketType.ISP_HLV; _this.ReqI = 0; /** Player's unique id */ _this.PLID = 0; /** 0: ground / 1: wall / 4: speeding / 5: out of bounds */ _this.HLVC = 0; _this.Sp1 = 0; _this.SpW = 0; /** Time stamp (ms) */ _this.Time = 0; /** Car contact object */ _this.C = new structs_1.CarContOBJ(); return _this; } IS_HLV.prototype.unpack = function (buffer) { _super.prototype.unpack.call(this, buffer); var start = this.getFormatSize(); var carContactBuffer = (0, lfspack_1.copyBuffer)(buffer.slice(start, start + new structs_1.CarContOBJ().getFormatSize())); this.C = new structs_1.CarContOBJ().unpack(carContactBuffer); return this; }; __decorate([ (0, decorators_1.byte)() ], IS_HLV.prototype, "Size", void 0); __decorate([ (0, decorators_1.byte)() ], IS_HLV.prototype, "Type", void 0); __decorate([ (0, decorators_1.byte)() ], IS_HLV.prototype, "ReqI", void 0); __decorate([ (0, decorators_1.byte)() ], IS_HLV.prototype, "PLID", void 0); __decorate([ (0, decorators_1.byte)() ], IS_HLV.prototype, "HLVC", void 0); __decorate([ (0, decorators_1.byte)() ], IS_HLV.prototype, "Sp1", void 0); __decorate([ (0, decorators_1.word)() ], IS_HLV.prototype, "SpW", void 0); __decorate([ (0, decorators_1.unsigned)() ], IS_HLV.prototype, "Time", void 0); return IS_HLV; }(base_1.Packet)); exports.IS_HLV = IS_HLV; var HLVCViolation; (function (HLVCViolation) { /** Car drove off track */ HLVCViolation[HLVCViolation["GROUND"] = 0] = "GROUND"; /** Car hit a wall */ HLVCViolation[HLVCViolation["WALL"] = 1] = "WALL"; /** Car was speeding in pit lane */ HLVCViolation[HLVCViolation["SPEEDING"] = 4] = "SPEEDING"; /** Car went out of bounds */ HLVCViolation[HLVCViolation["OUT_OF_BOUNDS"] = 5] = "OUT_OF_BOUNDS"; })(HLVCViolation || (exports.HLVCViolation = HLVCViolation = {}));