UNPKG

tsinsim

Version:

An InSim library for Node.js (JavaScript runtime environment) with TypeScript support.

83 lines (82 loc) 2.81 kB
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 __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { Sendable } from "../../utilities/index.js"; import { define, byte } from "../../utilities/decorators.js"; import { PacketType } from "../../types/PacketType.js"; let IS_MAL = class IS_MAL extends Sendable { constructor(options = {}) { super(); Object.assign(this, options); } Size = 8; Type = PacketType.ISP_MAL; ReqI = 0; NumM = 0; UCID = 0; Flags = 0; Sp2 = 0; Sp3 = 0; SkinID = []; pack() { this.SkinID = this.SkinID.slice(0, 120).filter(s => s.length == 6); this.NumM = this.SkinID.length; var buffer = super.pack(this.Size + this.SkinID.length * 4); for (const id of this.SkinID) { buffer = Buffer.concat([buffer, Buffer.from('00' + id, 'hex').reverse()]); } return buffer; } unpack(data) { super.unpack(data); const buf = data.subarray(8, data.length); for (var i = 0; i < (data.length - 8) / 4; i++) { const mbuf = buf.subarray(i * 4, i * 4 + 4).reverse().subarray(1, 4).toString('hex'); this.SkinID.push(mbuf); } return this; } }; __decorate([ byte(), __metadata("design:type", Object) ], IS_MAL.prototype, "Size", void 0); __decorate([ byte(), __metadata("design:type", Object) ], IS_MAL.prototype, "Type", void 0); __decorate([ byte(), __metadata("design:type", Object) ], IS_MAL.prototype, "ReqI", void 0); __decorate([ byte(), __metadata("design:type", Object) ], IS_MAL.prototype, "NumM", void 0); __decorate([ byte(), __metadata("design:type", Object) ], IS_MAL.prototype, "UCID", void 0); __decorate([ byte(), __metadata("design:type", Object) ], IS_MAL.prototype, "Flags", void 0); __decorate([ byte(), __metadata("design:type", Object) ], IS_MAL.prototype, "Sp2", void 0); __decorate([ byte(), __metadata("design:type", Object) ], IS_MAL.prototype, "Sp3", void 0); IS_MAL = __decorate([ define, __metadata("design:paramtypes", [Object]) ], IS_MAL); export { IS_MAL };