// This file has been automatically generated by writeMessageClasses.js import { UUID } from '../UUID'; import { MessageFlags } from '../../enums/MessageFlags'; import { MessageBase } from '../MessageBase'; import { Message } from '../../enums/Message'; export class TransferInventoryMessage implements MessageBase { name = 'TransferInventory'; messageFlags = MessageFlags.Trusted | MessageFlags.Zerocoded | MessageFlags.FrequencyLow; id = Message.TransferInventory; InfoBlock: { SourceID: UUID; DestID: UUID; TransactionID: UUID; }; InventoryBlock: { InventoryID: UUID; Type: number; }[]; getSize(): number { return ((17) * this.InventoryBlock.length) + 49; } // @ts-ignore writeToBuffer(buf: Buffer, pos: number): number { const startPos = pos; this.InfoBlock['SourceID'].writeToBuffer(buf, pos); pos += 16; this.InfoBlock['DestID'].writeToBuffer(buf, pos); pos += 16; this.InfoBlock['TransactionID'].writeToBuffer(buf, pos); pos += 16; const count = this.InventoryBlock.length; buf.writeUInt8(this.InventoryBlock.length, pos++); for (let i = 0; i < count; i++) { this.InventoryBlock[i]['InventoryID'].writeToBuffer(buf, pos); pos += 16; buf.writeInt8(this.InventoryBlock[i]['Type'], pos++); } return pos - startPos; } // @ts-ignore readFromBuffer(buf: Buffer, pos: number): number { const startPos = pos; const newObjInfoBlock: { SourceID: UUID, DestID: UUID, TransactionID: UUID } = { SourceID: UUID.zero(), DestID: UUID.zero(), TransactionID: UUID.zero() }; newObjInfoBlock['SourceID'] = new UUID(buf, pos); pos += 16; newObjInfoBlock['DestID'] = new UUID(buf, pos); pos += 16; newObjInfoBlock['TransactionID'] = new UUID(buf, pos); pos += 16; this.InfoBlock = newObjInfoBlock; if (pos >= buf.length) { return pos - startPos; } const count = buf.readUInt8(pos++); this.InventoryBlock = []; for (let i = 0; i < count; i++) { const newObjInventoryBlock: { InventoryID: UUID, Type: number } = { InventoryID: UUID.zero(), Type: 0 }; newObjInventoryBlock['InventoryID'] = new UUID(buf, pos); pos += 16; newObjInventoryBlock['Type'] = buf.readInt8(pos++); this.InventoryBlock.push(newObjInventoryBlock); } return pos - startPos; } }