UNPKG

node-insim

Version:

An InSim library for NodeJS with TypeScript support

114 lines (113 loc) 4.8 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.CarContactFlags = exports.CarContact = void 0; var decorators_1 = require("../../decorators"); var base_1 = require("../base"); var CarContact = /** @class */ (function (_super) { __extends(CarContact, _super); function CarContact(data) { var _this = _super.call(this) || this; _this.PLID = 0; /** Like Info byte in {@link CompCar} (CCI_BLUE / CCI_YELLOW / CCI_LAG) */ _this.Info = 0; _this.Sp2 = 0; /** Front wheel steer in degrees (right positive) */ _this.Steer = 0; /** High 4 bits: throttle / low 4 bits: brake (0 to 15) */ _this.ThrBrk = 0; /** High 4 bits: clutch / low 4 bits: handbrake (0 to 15) */ _this.CluHan = 0; /** High 4 bits: gear (15=R) / low 4 bits: spare */ _this.GearSp = 0; /** m/s */ _this.Speed = 0; /** Car's motion if Speed > 0: 0 = world y direction, 128 = 180 deg */ _this.Direction = 0; /** Direction of forward axis: 0 = world y direction, 128 = 180 deg */ _this.Heading = 0; /** m/s^2 longitudinal acceleration (forward positive) */ _this.AccelF = 0; /** m/s^2 lateral acceleration (right positive) */ _this.AccelR = 0; /** Position (1 metre = 16) */ _this.X = 0; /** Position (1 metre = 16) */ _this.Y = 0; _this.initialize(data); return _this; } __decorate([ (0, decorators_1.byte)() ], CarContact.prototype, "PLID", void 0); __decorate([ (0, decorators_1.byte)() ], CarContact.prototype, "Info", void 0); __decorate([ (0, decorators_1.byte)() ], CarContact.prototype, "Sp2", void 0); __decorate([ (0, decorators_1.char)() ], CarContact.prototype, "Steer", void 0); __decorate([ (0, decorators_1.byte)() ], CarContact.prototype, "ThrBrk", void 0); __decorate([ (0, decorators_1.byte)() ], CarContact.prototype, "CluHan", void 0); __decorate([ (0, decorators_1.byte)() ], CarContact.prototype, "GearSp", void 0); __decorate([ (0, decorators_1.byte)() ], CarContact.prototype, "Speed", void 0); __decorate([ (0, decorators_1.byte)() ], CarContact.prototype, "Direction", void 0); __decorate([ (0, decorators_1.byte)() ], CarContact.prototype, "Heading", void 0); __decorate([ (0, decorators_1.char)() ], CarContact.prototype, "AccelF", void 0); __decorate([ (0, decorators_1.char)() ], CarContact.prototype, "AccelR", void 0); __decorate([ (0, decorators_1.short)() ], CarContact.prototype, "X", void 0); __decorate([ (0, decorators_1.short)() ], CarContact.prototype, "Y", void 0); return CarContact; }(base_1.Struct)); exports.CarContact = CarContact; var CarContactFlags; (function (CarContactFlags) { /** This car is in the way of a driver who is a lap ahead */ CarContactFlags[CarContactFlags["CCI_BLUE"] = 1] = "CCI_BLUE"; /** This car is slow or stopped and in a dangerous place */ CarContactFlags[CarContactFlags["CCI_YELLOW"] = 2] = "CCI_YELLOW"; /** This car is lagging (missing or delayed position packets) */ CarContactFlags[CarContactFlags["CCI_LAG"] = 32] = "CCI_LAG"; })(CarContactFlags || (exports.CarContactFlags = CarContactFlags = {}));