// 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 { UUID, UUIDT } from '../common/uuid.js';


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

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

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

id(obj?:UUID):UUID|null {
  const offset = this.bb!.__offset(this.bb_pos, 4);
  return offset ? (obj || new UUID()).__init(this.bb_pos + offset, this.bb!) : null;
}

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

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

static startBattleSummary(builder:flatbuffers.Builder) {
  builder.startObject(3);
}

static addId(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset) {
  builder.addFieldStruct(0, idOffset, 0);
}

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

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

static endBattleSummary(builder:flatbuffers.Builder):flatbuffers.Offset {
  const offset = builder.endObject();
  builder.requiredField(offset, 4) // id
  return offset;
}

static createBattleSummary(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset, planet:bigint, shots:bigint):flatbuffers.Offset {
  BattleSummary.startBattleSummary(builder);
  BattleSummary.addId(builder, idOffset);
  BattleSummary.addPlanet(builder, planet);
  BattleSummary.addShots(builder, shots);
  return BattleSummary.endBattleSummary(builder);
}

unpack(): BattleSummaryT {
  return new BattleSummaryT(
    (this.id() !== null ? this.id()!.unpack() : null),
    this.planet(),
    this.shots()
  );
}


unpackTo(_o: BattleSummaryT): void {
  _o.id = (this.id() !== null ? this.id()!.unpack() : null);
  _o.planet = this.planet();
  _o.shots = this.shots();
}
}

export class BattleSummaryT implements flatbuffers.IGeneratedObject {
constructor(
  public id: UUIDT|null = null,
  public planet: bigint = BigInt('0'),
  public shots: bigint = BigInt('0')
){}


pack(builder:flatbuffers.Builder): flatbuffers.Offset {
  return BattleSummary.createBattleSummary(builder,
    (this.id !== null ? this.id!.pack(builder) : 0),
    this.planet,
    this.shots
  );
}
}
