UNPKG

node-insim

Version:

An InSim library for NodeJS with TypeScript support

147 lines (146 loc) 5.76 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.UCOAction = exports.IS_UCO = void 0; var decorators_1 = require("../decorators"); var base_1 = require("./base"); var enums_1 = require("./enums"); var structs_1 = require("./structs"); /** * User Control Object * * Reports crossing an InSim checkpoint / entering an InSim circle (from layout). */ var IS_UCO = /** @class */ (function (_super) { __extends(IS_UCO, _super); function IS_UCO() { var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this; _this.Size = 28; _this.Type = enums_1.PacketType.ISP_UCO; _this.ReqI = 0; /** Player's unique id */ _this.PLID = 0; _this.Sp0 = 0; /** Entering/leaving a circle or crossing a checkpoint */ _this.UCOAction = 0; _this.Sp2 = 0; _this.Sp3 = 0; /** Milliseconds since start (as in {@link SMALL_RTP}) */ _this.Time = 0; /** Car contact object */ _this.C = new structs_1.CarContOBJ(); /** * Info about the checkpoint or circle * * Identifying an InSim checkpoint: * * Index is 252. Checkpoint index (seen in the layout editor) is stored in Flags * bits 0 and 1. * * - 00 = finish line * - 01 = 1st checkpoint * - 10 = 2nd checkpoint * - 11 = 3rd checkpoint * * Note that the checkpoint index has no meaning in LFS and is provided only for your convenience. * If you use many InSim checkpoints you may need to identify them with the X and Y values. * * Identifying an InSim circle: * * Index is 253. The circle index (seen in the layout editor) is stored in the Heading byte. */ _this.Info = new structs_1.ObjectInfo(); return _this; } __decorate([ (0, decorators_1.byte)() ], IS_UCO.prototype, "Size", void 0); __decorate([ (0, decorators_1.byte)() ], IS_UCO.prototype, "Type", void 0); __decorate([ (0, decorators_1.byte)() ], IS_UCO.prototype, "ReqI", void 0); __decorate([ (0, decorators_1.byte)() ], IS_UCO.prototype, "PLID", void 0); __decorate([ (0, decorators_1.byte)() ], IS_UCO.prototype, "Sp0", void 0); __decorate([ (0, decorators_1.byte)() ], IS_UCO.prototype, "UCOAction", void 0); __decorate([ (0, decorators_1.byte)() ], IS_UCO.prototype, "Sp2", void 0); __decorate([ (0, decorators_1.byte)() ], IS_UCO.prototype, "Sp3", void 0); __decorate([ (0, decorators_1.unsigned)() ], IS_UCO.prototype, "Time", void 0); __decorate([ (0, decorators_1.struct)(structs_1.CarContOBJ) ], IS_UCO.prototype, "C", void 0); __decorate([ (0, decorators_1.struct)(structs_1.ObjectInfo) ], IS_UCO.prototype, "Info", void 0); return IS_UCO; }(base_1.Packet)); exports.IS_UCO = IS_UCO; var UCOAction; (function (UCOAction) { /** Etered a circle */ UCOAction[UCOAction["UCO_CIRCLE_ENTER"] = 0] = "UCO_CIRCLE_ENTER"; /** Left a circle */ UCOAction[UCOAction["UCO_CIRCLE_LEAVE"] = 1] = "UCO_CIRCLE_LEAVE"; /** Crossed a checkpoint in forward direction */ UCOAction[UCOAction["UCO_CP_FWD"] = 2] = "UCO_CP_FWD"; /** Crossed a checkpoint in reverse direction */ UCOAction[UCOAction["UCO_CP_REV"] = 3] = "UCO_CP_REV"; })(UCOAction || (exports.UCOAction = UCOAction = {}));