// 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 { TechEntry, TechEntryT } from '../battle/tech-entry.js';


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

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

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

inBattle():boolean {
  const offset = this.bb!.__offset(this.bb_pos, 4);
  return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false;
}

number():bigint {
  const offset = this.bb!.__offset(this.bb_pos, 6);
  return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}

numberLeft():bigint {
  const offset = this.bb!.__offset(this.bb_pos, 8);
  return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}

loadQuantity():number {
  const offset = this.bb!.__offset(this.bb_pos, 10);
  return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}

tech(index: number, obj?:TechEntry):TechEntry|null {
  const offset = this.bb!.__offset(this.bb_pos, 12);
  return offset ? (obj || new TechEntry()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}

techLength():number {
  const offset = this.bb!.__offset(this.bb_pos, 12);
  return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}

race():string|null
race(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
race(optionalEncoding?:any):string|Uint8Array|null {
  const offset = this.bb!.__offset(this.bb_pos, 14);
  return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}

className():string|null
className(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
className(optionalEncoding?:any):string|Uint8Array|null {
  const offset = this.bb!.__offset(this.bb_pos, 16);
  return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}

loadType():string|null
loadType(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
loadType(optionalEncoding?:any):string|Uint8Array|null {
  const offset = this.bb!.__offset(this.bb_pos, 18);
  return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}

static startBattleReportGroup(builder:flatbuffers.Builder) {
  builder.startObject(8);
}

static addInBattle(builder:flatbuffers.Builder, inBattle:boolean) {
  builder.addFieldInt8(0, +inBattle, +false);
}

static addNumber(builder:flatbuffers.Builder, number:bigint) {
  builder.addFieldInt64(1, number, BigInt('0'));
}

static addNumberLeft(builder:flatbuffers.Builder, numberLeft:bigint) {
  builder.addFieldInt64(2, numberLeft, BigInt('0'));
}

static addLoadQuantity(builder:flatbuffers.Builder, loadQuantity:number) {
  builder.addFieldFloat32(3, loadQuantity, 0.0);
}

static addTech(builder:flatbuffers.Builder, techOffset:flatbuffers.Offset) {
  builder.addFieldOffset(4, techOffset, 0);
}

static createTechVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
  builder.startVector(4, data.length, 4);
  for (let i = data.length - 1; i >= 0; i--) {
    builder.addOffset(data[i]!);
  }
  return builder.endVector();
}

static startTechVector(builder:flatbuffers.Builder, numElems:number) {
  builder.startVector(4, numElems, 4);
}

static addRace(builder:flatbuffers.Builder, raceOffset:flatbuffers.Offset) {
  builder.addFieldOffset(5, raceOffset, 0);
}

static addClassName(builder:flatbuffers.Builder, classNameOffset:flatbuffers.Offset) {
  builder.addFieldOffset(6, classNameOffset, 0);
}

static addLoadType(builder:flatbuffers.Builder, loadTypeOffset:flatbuffers.Offset) {
  builder.addFieldOffset(7, loadTypeOffset, 0);
}

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

static createBattleReportGroup(builder:flatbuffers.Builder, inBattle:boolean, number:bigint, numberLeft:bigint, loadQuantity:number, techOffset:flatbuffers.Offset, raceOffset:flatbuffers.Offset, classNameOffset:flatbuffers.Offset, loadTypeOffset:flatbuffers.Offset):flatbuffers.Offset {
  BattleReportGroup.startBattleReportGroup(builder);
  BattleReportGroup.addInBattle(builder, inBattle);
  BattleReportGroup.addNumber(builder, number);
  BattleReportGroup.addNumberLeft(builder, numberLeft);
  BattleReportGroup.addLoadQuantity(builder, loadQuantity);
  BattleReportGroup.addTech(builder, techOffset);
  BattleReportGroup.addRace(builder, raceOffset);
  BattleReportGroup.addClassName(builder, classNameOffset);
  BattleReportGroup.addLoadType(builder, loadTypeOffset);
  return BattleReportGroup.endBattleReportGroup(builder);
}

unpack(): BattleReportGroupT {
  return new BattleReportGroupT(
    this.inBattle(),
    this.number(),
    this.numberLeft(),
    this.loadQuantity(),
    this.bb!.createObjList<TechEntry, TechEntryT>(this.tech.bind(this), this.techLength()),
    this.race(),
    this.className(),
    this.loadType()
  );
}


unpackTo(_o: BattleReportGroupT): void {
  _o.inBattle = this.inBattle();
  _o.number = this.number();
  _o.numberLeft = this.numberLeft();
  _o.loadQuantity = this.loadQuantity();
  _o.tech = this.bb!.createObjList<TechEntry, TechEntryT>(this.tech.bind(this), this.techLength());
  _o.race = this.race();
  _o.className = this.className();
  _o.loadType = this.loadType();
}
}

export class BattleReportGroupT implements flatbuffers.IGeneratedObject {
constructor(
  public inBattle: boolean = false,
  public number: bigint = BigInt('0'),
  public numberLeft: bigint = BigInt('0'),
  public loadQuantity: number = 0.0,
  public tech: (TechEntryT)[] = [],
  public race: string|Uint8Array|null = null,
  public className: string|Uint8Array|null = null,
  public loadType: string|Uint8Array|null = null
){}


pack(builder:flatbuffers.Builder): flatbuffers.Offset {
  const tech = BattleReportGroup.createTechVector(builder, builder.createObjectOffsetList(this.tech));
  const race = (this.race !== null ? builder.createString(this.race!) : 0);
  const className = (this.className !== null ? builder.createString(this.className!) : 0);
  const loadType = (this.loadType !== null ? builder.createString(this.loadType!) : 0);

  return BattleReportGroup.createBattleReportGroup(builder,
    this.inBattle,
    this.number,
    this.numberLeft,
    this.loadQuantity,
    tech,
    race,
    className,
    loadType
  );
}
}
