UNPKG

node-insim

Version:

An InSim library for NodeJS with TypeScript support

45 lines (44 loc) 1.4 kB
import { __decorate } from "tslib"; import { byte } from '../decorators'; import { SendablePacket } from './base'; import { PacketType } from './enums'; /** * HandiCaPs * * You can send a packet to add mass and restrict the intake on each car model. * The same restriction applies to all drivers using a particular car model. * This can be useful for creating multi class hosts. */ export class IS_HCP extends SendablePacket { constructor(data) { super(); this.Size = 68; this.Type = PacketType.ISP_HCP; this.ReqI = 0; this.Zero = 0; /** H_Mass and H_TRes for each car: XF GTI = 0 / XR GT = 1 etc. */ this.Info = []; this.initialize(data); } pack() { if (this.Info.length !== IS_HCP.MAX_CARS) { throw new RangeError(`IS_HCP - Info property must have exactly ${IS_HCP.MAX_CARS} items`); } const dataBuffer = super.pack(); const infoBuffer = this.Info.reduce((acc, info) => new Uint8Array([...acc, ...info.pack()]), new Uint8Array()); return new Uint8Array([...dataBuffer, ...infoBuffer]); } } IS_HCP.MAX_CARS = 32; __decorate([ byte() ], IS_HCP.prototype, "Size", void 0); __decorate([ byte() ], IS_HCP.prototype, "Type", void 0); __decorate([ byte() ], IS_HCP.prototype, "ReqI", void 0); __decorate([ byte() ], IS_HCP.prototype, "Zero", void 0);