UNPKG

node-insim

Version:

An InSim library for NodeJS with TypeScript support

116 lines (115 loc) 4.82 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; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.CompCarFlags = exports.CompCar = void 0; var decorators_1 = require("../../decorators"); var base_1 = require("../base"); var CompCar = /** @class */ (function (_super) { __extends(CompCar, _super); function CompCar(data) { var _this = _super.call(this) || this; /** Current path node */ _this.Node = 0; /** Current lap */ _this.Lap = 0; /** Player's unique id */ _this.PLID = 0; /** Current race position: 0 = unknown, 1 = leader, etc... */ _this.Position = 0; /** Flags and other info */ _this.Info = 0; _this.Sp3 = 0; /** X map (65536 = 1 metre) */ _this.X = 0; /** Y map (65536 = 1 metre) */ _this.Y = 0; /** Z alt (65536 = 1 metre) */ _this.Z = 0; /** Speed (32768 = 100 m/s) */ _this.Speed = 0; /** car's motion if Speed > 0: 0 = world y direction, 32768 = 180 deg */ _this.Direction = 0; /** direction of forward axis: 0 = world y direction, 32768 = 180 deg anticlockwise from above */ _this.Heading = 0; /** Signed, rate of change of heading: (8192 = 180 deg/s anticlockwise) */ _this.AngVel = 0; _this.initialize(data); return _this; } __decorate([ (0, decorators_1.word)() ], CompCar.prototype, "Node", void 0); __decorate([ (0, decorators_1.word)() ], CompCar.prototype, "Lap", void 0); __decorate([ (0, decorators_1.byte)() ], CompCar.prototype, "PLID", void 0); __decorate([ (0, decorators_1.byte)() ], CompCar.prototype, "Position", void 0); __decorate([ (0, decorators_1.byte)() ], CompCar.prototype, "Info", void 0); __decorate([ (0, decorators_1.byte)() ], CompCar.prototype, "Sp3", void 0); __decorate([ (0, decorators_1.int)() ], CompCar.prototype, "X", void 0); __decorate([ (0, decorators_1.int)() ], CompCar.prototype, "Y", void 0); __decorate([ (0, decorators_1.int)() ], CompCar.prototype, "Z", void 0); __decorate([ (0, decorators_1.word)() ], CompCar.prototype, "Speed", void 0); __decorate([ (0, decorators_1.word)() ], CompCar.prototype, "Direction", void 0); __decorate([ (0, decorators_1.word)() ], CompCar.prototype, "Heading", void 0); __decorate([ (0, decorators_1.short)() ], CompCar.prototype, "AngVel", void 0); return CompCar; }(base_1.Struct)); exports.CompCar = CompCar; var CompCarFlags; (function (CompCarFlags) { /** This car is in the way of a driver who is a lap ahead */ CompCarFlags[CompCarFlags["CCI_BLUE"] = 1] = "CCI_BLUE"; /** This car is slow or stopped and in a dangerous place */ CompCarFlags[CompCarFlags["CCI_YELLOW"] = 2] = "CCI_YELLOW"; /** This car is outside the path */ CompCarFlags[CompCarFlags["CCI_OOB"] = 4] = "CCI_OOB"; /** This car is lagging (missing or delayed position packets) */ CompCarFlags[CompCarFlags["CCI_LAG"] = 32] = "CCI_LAG"; /** This is the first compcar in this set of MCI packets */ CompCarFlags[CompCarFlags["CCI_FIRST"] = 64] = "CCI_FIRST"; /** This is the last compcar in this set of MCI packets */ CompCarFlags[CompCarFlags["CCI_LAST"] = 128] = "CCI_LAST"; })(CompCarFlags || (exports.CompCarFlags = CompCarFlags = {}));