UNPKG

tsinsim

Version:

An InSim library for Node.js (JavaScript runtime environment) with TypeScript support.

173 lines (172 loc) 5.09 kB
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 __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { Receivable } from "../../utilities/index.js"; import { define, byte, char, word, unsigned } from "../../utilities/decorators.js"; import { PacketType } from "../../types/PacketType.js"; import { PlayerType, TyreCompound } from "../../enums/index.js"; const OFFICIAL_VEHICLES = ['UF1', 'XFG', 'XRG', 'LX4', 'LX6', 'RB4', 'FXO', 'XRT', 'RAC', 'FZ5', 'UFR', 'XFR', 'FXR', 'XRR', 'FZR', 'MRT', 'FBM', 'FOX', 'FO8', 'BF1']; let IS_NPL = class IS_NPL extends Receivable { Size = 76; Type = PacketType.ISP_NPL; ReqI = 0; PLID = 0; UCID = 0; PType = 0; Flags = 0; PName = ''; Plate = ''; CName = ''; CNameInt = 0; SName = ''; TyreRL = 0; TyreRR = 0; TyreFL = 0; TyreFR = 0; H_Mass = 0; H_TRes = 0; Model = 0; Pass = 0; RWAdj = 0; FWADj = 0; Sp2 = 0; Sp3 = 0; SetF = 0; NumP = 0; Config = 0; Fuel = 0; unpack(data) { const buffer = super.unpack(data); var OfficialName = false; for (const vehName of OFFICIAL_VEHICLES) { const oid = Buffer.concat([Buffer.from(vehName), Buffer.alloc(1)]).readUInt32LE(0).toString(16); if (oid == buffer.CNameInt.toString(16)) { OfficialName = vehName; } } buffer.CName = OfficialName ? OfficialName : buffer.CNameInt.toString(16).toUpperCase(); return this; } }; __decorate([ byte(), __metadata("design:type", Object) ], IS_NPL.prototype, "Size", void 0); __decorate([ byte(), __metadata("design:type", Object) ], IS_NPL.prototype, "Type", void 0); __decorate([ byte(), __metadata("design:type", Object) ], IS_NPL.prototype, "ReqI", void 0); __decorate([ byte(), __metadata("design:type", Object) ], IS_NPL.prototype, "PLID", void 0); __decorate([ byte(), __metadata("design:type", Object) ], IS_NPL.prototype, "UCID", void 0); __decorate([ byte(), __metadata("design:type", Number) ], IS_NPL.prototype, "PType", void 0); __decorate([ word(), __metadata("design:type", Number) ], IS_NPL.prototype, "Flags", void 0); __decorate([ char(24), __metadata("design:type", Object) ], IS_NPL.prototype, "PName", void 0); __decorate([ char(8), __metadata("design:type", Object) ], IS_NPL.prototype, "Plate", void 0); __decorate([ char(0), __metadata("design:type", Object) ], IS_NPL.prototype, "CName", void 0); __decorate([ unsigned(), __metadata("design:type", Object) ], IS_NPL.prototype, "CNameInt", void 0); __decorate([ char(16), __metadata("design:type", Object) ], IS_NPL.prototype, "SName", void 0); __decorate([ byte(), __metadata("design:type", Number) ], IS_NPL.prototype, "TyreRL", void 0); __decorate([ byte(), __metadata("design:type", Number) ], IS_NPL.prototype, "TyreRR", void 0); __decorate([ byte(), __metadata("design:type", Number) ], IS_NPL.prototype, "TyreFL", void 0); __decorate([ byte(), __metadata("design:type", Number) ], IS_NPL.prototype, "TyreFR", void 0); __decorate([ byte(), __metadata("design:type", Object) ], IS_NPL.prototype, "H_Mass", void 0); __decorate([ byte(), __metadata("design:type", Object) ], IS_NPL.prototype, "H_TRes", void 0); __decorate([ byte(), __metadata("design:type", Object) ], IS_NPL.prototype, "Model", void 0); __decorate([ byte(), __metadata("design:type", Number) ], IS_NPL.prototype, "Pass", void 0); __decorate([ byte(), __metadata("design:type", Object) ], IS_NPL.prototype, "RWAdj", void 0); __decorate([ byte(), __metadata("design:type", Object) ], IS_NPL.prototype, "FWADj", void 0); __decorate([ byte(), __metadata("design:type", Object) ], IS_NPL.prototype, "Sp2", void 0); __decorate([ byte(), __metadata("design:type", Object) ], IS_NPL.prototype, "Sp3", void 0); __decorate([ byte(), __metadata("design:type", Number) ], IS_NPL.prototype, "SetF", void 0); __decorate([ byte(), __metadata("design:type", Object) ], IS_NPL.prototype, "NumP", void 0); __decorate([ byte(), __metadata("design:type", Object) ], IS_NPL.prototype, "Config", void 0); __decorate([ byte(), __metadata("design:type", Object) ], IS_NPL.prototype, "Fuel", void 0); IS_NPL = __decorate([ define ], IS_NPL); export { IS_NPL };