UNPKG

node-insim

Version:

An InSim library for NodeJS with TypeScript support

115 lines (113 loc) 4.99 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.JRRAction = exports.IS_JRR = void 0; var decorators_1 = require("../decorators"); var base_1 = require("./base"); var enums_1 = require("./enums"); var structs_1 = require("./structs"); /** * Join Request Reply - send one of these back to LFS in response to a join request * * Set the {@link ISF_REQ_JOIN} flag in the {@link IS_ISI} to receive join requests * A join request is seen as an {@link IS_NPL} packet with ZERO in the NumP field * An immediate response (e.g. within 1 second) is required using an {@link IS_JRR} packet * * In this case, PLID must be zero and {@link JRRAction} must be {@link JRR_REJECT} or * {@link JRR_SPAWN}. * If you allow the join and it is successful you will then get a normal {@link IS_NPL} with * NumP set. * You can also specify the start position of the car using the StartPos structure. * * {@link IS_JRR} can also be used to move an existing car to a different location. * In this case, {@link PLID} must be set, {@link JRRAction} must be {@link JRR_RESET} or * higher and StartPos must be set. */ var IS_JRR = /** @class */ (function (_super) { __extends(IS_JRR, _super); function IS_JRR(data) { var _this = _super.call(this) || this; _this.Size = 16; _this.Type = enums_1.PacketType.ISP_JRR; _this.ReqI = 0; /** ZERO when this is a reply to a join request - SET to move a car */ _this.PLID = 0; /** Set when this is a reply to a join request - ignored when moving a car */ _this.UCID = 0; /** 1 - allow / 0 - reject (should send message to user) */ _this.JRRAction = 0; _this.Sp2 = 0; _this.Sp3 = 0; /** * 0: use default start point / Flags = 0x80: set start point * * To use default start point, StartPos should be filled with zero values. * * To specify a start point, StartPos X, Y, Zbyte and Heading should be filled like * an autocross start position, Flags should be 0x80 and Index should be zero */ _this.StartPos = new structs_1.ObjectInfo(); _this.initialize(data); return _this; } __decorate([ (0, decorators_1.byte)() ], IS_JRR.prototype, "Size", void 0); __decorate([ (0, decorators_1.byte)() ], IS_JRR.prototype, "Type", void 0); __decorate([ (0, decorators_1.byte)() ], IS_JRR.prototype, "ReqI", void 0); __decorate([ (0, decorators_1.byte)() ], IS_JRR.prototype, "PLID", void 0); __decorate([ (0, decorators_1.byte)() ], IS_JRR.prototype, "UCID", void 0); __decorate([ (0, decorators_1.byte)() ], IS_JRR.prototype, "JRRAction", void 0); __decorate([ (0, decorators_1.byte)() ], IS_JRR.prototype, "Sp2", void 0); __decorate([ (0, decorators_1.byte)() ], IS_JRR.prototype, "Sp3", void 0); __decorate([ (0, decorators_1.struct)(structs_1.ObjectInfo) ], IS_JRR.prototype, "StartPos", void 0); return IS_JRR; }(base_1.SendablePacket)); exports.IS_JRR = IS_JRR; var JRRAction; (function (JRRAction) { /** Reject new player */ JRRAction[JRRAction["JRR_REJECT"] = 0] = "JRR_REJECT"; /** Allow new player */ JRRAction[JRRAction["JRR_SPAWN"] = 1] = "JRR_SPAWN"; /** Reset player's car */ JRRAction[JRRAction["JRR_RESET"] = 4] = "JRR_RESET"; /** Reset player's car without repairing damage */ JRRAction[JRRAction["JRR_RESET_NO_REPAIR"] = 5] = "JRR_RESET_NO_REPAIR"; })(JRRAction || (exports.JRRAction = JRRAction = {}));