// automatically generated by the FlatBuffers compiler, do not modify

/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */

import * as flatbuffers from 'flatbuffers';

import { BattleReportGroup, BattleReportGroupT } from '../battle/battle-report-group.js';


export class ShipEntry implements flatbuffers.IUnpackableObject<ShipEntryT> {
  bb: flatbuffers.ByteBuffer|null = null;
  bb_pos = 0;
  __init(i:number, bb:flatbuffers.ByteBuffer):ShipEntry {
  this.bb_pos = i;
  this.bb = bb;
  return this;
}

static getRootAsShipEntry(bb:flatbuffers.ByteBuffer, obj?:ShipEntry):ShipEntry {
  return (obj || new ShipEntry()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

static getSizePrefixedRootAsShipEntry(bb:flatbuffers.ByteBuffer, obj?:ShipEntry):ShipEntry {
  bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
  return (obj || new ShipEntry()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

key():bigint {
  const offset = this.bb!.__offset(this.bb_pos, 4);
  return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
}

value(obj?:BattleReportGroup):BattleReportGroup|null {
  const offset = this.bb!.__offset(this.bb_pos, 6);
  return offset ? (obj || new BattleReportGroup()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
}

static startShipEntry(builder:flatbuffers.Builder) {
  builder.startObject(2);
}

static addKey(builder:flatbuffers.Builder, key:bigint) {
  builder.addFieldInt64(0, key, BigInt('0'));
}

static addValue(builder:flatbuffers.Builder, valueOffset:flatbuffers.Offset) {
  builder.addFieldOffset(1, valueOffset, 0);
}

static endShipEntry(builder:flatbuffers.Builder):flatbuffers.Offset {
  const offset = builder.endObject();
  return offset;
}


unpack(): ShipEntryT {
  return new ShipEntryT(
    this.key(),
    (this.value() !== null ? this.value()!.unpack() : null)
  );
}


unpackTo(_o: ShipEntryT): void {
  _o.key = this.key();
  _o.value = (this.value() !== null ? this.value()!.unpack() : null);
}
}

export class ShipEntryT implements flatbuffers.IGeneratedObject {
constructor(
  public key: bigint = BigInt('0'),
  public value: BattleReportGroupT|null = null
){}


pack(builder:flatbuffers.Builder): flatbuffers.Offset {
  const value = (this.value !== null ? this.value!.pack(builder) : 0);

  ShipEntry.startShipEntry(builder);
  ShipEntry.addKey(builder, this.key);
  ShipEntry.addValue(builder, value);

  return ShipEntry.endShipEntry(builder);
}
}
