// 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 '../battle/uuid.js';


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

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

static getSizePrefixedRootAsRaceEntry(bb:flatbuffers.ByteBuffer, obj?:RaceEntry):RaceEntry {
  bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
  return (obj || new RaceEntry()).__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?:UUID):UUID|null {
  const offset = this.bb!.__offset(this.bb_pos, 6);
  return offset ? (obj || new UUID()).__init(this.bb_pos + offset, this.bb!) : null;
}

static startRaceEntry(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.addFieldStruct(1, valueOffset, 0);
}

static endRaceEntry(builder:flatbuffers.Builder):flatbuffers.Offset {
  const offset = builder.endObject();
  builder.requiredField(offset, 6) // value
  return offset;
}


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


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

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


pack(builder:flatbuffers.Builder): flatbuffers.Offset {
  RaceEntry.startRaceEntry(builder);
  RaceEntry.addKey(builder, this.key);
  RaceEntry.addValue(builder, (this.value !== null ? this.value!.pack(builder) : 0));

  return RaceEntry.endRaceEntry(builder);
}
}
