node-insim
Version:
An InSim library for NodeJS with TypeScript support
254 lines (253 loc) • 9.63 kB
JavaScript
;
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.SetupFlags = exports.PlayerType = exports.PassengerFlags = exports.CarConfiguration = exports.IS_NPL = void 0;
var decorators_1 = require("../decorators");
var base_1 = require("./base");
var enums_1 = require("./enums");
/**
* New PLayer joining race (if PLID already exists, then leaving pits)
*/
var IS_NPL = /** @class */ (function (_super) {
__extends(IS_NPL, _super);
function IS_NPL() {
var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
_this.Size = 76;
_this.Type = enums_1.PacketType.ISP_NPL;
/** 0 unless this is a reply to a {@link TINY_NPL} */
_this.ReqI = 0;
/** Player's newly assigned unique id */
_this.PLID = 0;
/** Connection's unique id */
_this.UCID = 0;
/** Bit 0: female / bit 1: AI / bit 2: remote */
_this.PType = 0;
/** Player flags */
_this.Flags = 0;
/** Nickname */
_this.PName = '';
/** Number plate - NO ZERO AT END! */
_this.Plate = '';
/**
* Car name
*
* The value can be one of these:
* - a 3-character abbreviation of an official LFS car (e.g. XRT)
* - a hexadecimal string representation of a car mod's SkinID (e.g. 5882E6)
*/
_this.CName = '';
/** Skin name - MAX_CAR_TEX_NAME */
_this.SName = '';
/** Rear left tyre compound */
_this.TyreRL = 0;
/** Rear right tyre compound */
_this.TyreRR = 0;
/** Front left tyre compound */
_this.TyreFL = 0;
/** Front right tyre compound */
_this.TyreFR = 0;
/** Added mass (kg) */
_this.H_Mass = 0;
/** Intake restriction */
_this.H_TRes = 0;
/** Driver model */
_this.Model = 0;
/** Passengers byte */
_this.Pass = 0;
/** Low 4 bits: tyre width reduction (rear) */
_this.RWAdj = 0;
/** Low 4 bits: tyre width reduction (front) */
_this.FWAdj = 0;
_this.Sp2 = 0;
_this.Sp3 = 0;
/** Setup flags */
_this.SetF = 0;
/** Number in race - ZERO if this is a join request */
_this.NumP = 0;
/**
* Configuration
*
* - UF1 / LX4 / LX6: 0 = DEFAULT / 1 = OPEN ROOF
* - GTR racing cars: 0 = DEFAULT / 1 = ALTERNATE
*/
_this.Config = CarConfiguration.DEFAULT;
/** /showfuel yes: fuel percent / no: 255 */
_this.Fuel = 0;
return _this;
}
__decorate([
(0, decorators_1.byte)()
], IS_NPL.prototype, "Size", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_NPL.prototype, "Type", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_NPL.prototype, "ReqI", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_NPL.prototype, "PLID", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_NPL.prototype, "UCID", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_NPL.prototype, "PType", void 0);
__decorate([
(0, decorators_1.word)()
], IS_NPL.prototype, "Flags", void 0);
__decorate([
(0, decorators_1.stringNull)(24)
], IS_NPL.prototype, "PName", void 0);
__decorate([
(0, decorators_1.string)(8)
], IS_NPL.prototype, "Plate", void 0);
__decorate([
(0, decorators_1.carName)()
], IS_NPL.prototype, "CName", void 0);
__decorate([
(0, decorators_1.stringNull)(16)
], IS_NPL.prototype, "SName", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_NPL.prototype, "TyreRL", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_NPL.prototype, "TyreRR", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_NPL.prototype, "TyreFL", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_NPL.prototype, "TyreFR", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_NPL.prototype, "H_Mass", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_NPL.prototype, "H_TRes", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_NPL.prototype, "Model", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_NPL.prototype, "Pass", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_NPL.prototype, "RWAdj", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_NPL.prototype, "FWAdj", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_NPL.prototype, "Sp2", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_NPL.prototype, "Sp3", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_NPL.prototype, "SetF", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_NPL.prototype, "NumP", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_NPL.prototype, "Config", void 0);
__decorate([
(0, decorators_1.byte)()
], IS_NPL.prototype, "Fuel", void 0);
return IS_NPL;
}(base_1.Packet));
exports.IS_NPL = IS_NPL;
var CarConfiguration;
(function (CarConfiguration) {
/** Default */
CarConfiguration[CarConfiguration["DEFAULT"] = 0] = "DEFAULT";
/**
* UF1 / LX4 / LX6 = open roof
* GTR racing cars = alternate
*/
CarConfiguration[CarConfiguration["OPEN_ROOF_OR_ALTERNATE"] = 1] = "OPEN_ROOF_OR_ALTERNATE";
})(CarConfiguration || (exports.CarConfiguration = CarConfiguration = {}));
var PassengerFlags;
(function (PassengerFlags) {
/** Front passenger is male */
PassengerFlags[PassengerFlags["FRONT_MALE"] = 1] = "FRONT_MALE";
/** Front passenger is female */
PassengerFlags[PassengerFlags["FRONT_FEMALE"] = 2] = "FRONT_FEMALE";
/** Rear-left passenger is male */
PassengerFlags[PassengerFlags["REAR_LEFT_MALE"] = 4] = "REAR_LEFT_MALE";
/** Rear-left passenger is female */
PassengerFlags[PassengerFlags["REAR_LEFT_FEMALE"] = 8] = "REAR_LEFT_FEMALE";
/** Rear-middle passenger is male */
PassengerFlags[PassengerFlags["REAR_MIDDLE_MALE"] = 16] = "REAR_MIDDLE_MALE";
/** Rear-middle passenger is female */
PassengerFlags[PassengerFlags["REAR_MIDDLE_FEMALE"] = 32] = "REAR_MIDDLE_FEMALE";
/** Rear-right passenger is male */
PassengerFlags[PassengerFlags["REAR_RIGHT_MALE"] = 64] = "REAR_RIGHT_MALE";
/** Rear-right passenger is female */
PassengerFlags[PassengerFlags["REAR_RIGHT_FEMALE"] = 128] = "REAR_RIGHT_FEMALE";
})(PassengerFlags || (exports.PassengerFlags = PassengerFlags = {}));
var PlayerType;
(function (PlayerType) {
/** Female */
PlayerType[PlayerType["FEMALE"] = 1] = "FEMALE";
/** AI */
PlayerType[PlayerType["AI"] = 2] = "AI";
/** Remote */
PlayerType[PlayerType["REMOTE"] = 4] = "REMOTE";
})(PlayerType || (exports.PlayerType = PlayerType = {}));
var SetupFlags;
(function (SetupFlags) {
/** Symmetrical wheels */
SetupFlags[SetupFlags["SETF_SYMM_WHEELS"] = 1] = "SETF_SYMM_WHEELS";
/** Traction control enabled */
SetupFlags[SetupFlags["SETF_TC_ENABLE"] = 2] = "SETF_TC_ENABLE";
/** Anti-lock brakes enabled */
SetupFlags[SetupFlags["SETF_ABS_ENABLE"] = 4] = "SETF_ABS_ENABLE";
})(SetupFlags || (exports.SetupFlags = SetupFlags = {}));