// 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 { Relation } from '../order/relation.js';


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

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

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

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

relation():Relation {
  const offset = this.bb!.__offset(this.bb_pos, 6);
  return offset ? this.bb!.readInt8(this.bb_pos + offset) : Relation.UNKNOWN;
}

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

static addAcceptor(builder:flatbuffers.Builder, acceptorOffset:flatbuffers.Offset) {
  builder.addFieldOffset(0, acceptorOffset, 0);
}

static addRelation(builder:flatbuffers.Builder, relation:Relation) {
  builder.addFieldInt8(1, relation, Relation.UNKNOWN);
}

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

static createCommandRaceRelation(builder:flatbuffers.Builder, acceptorOffset:flatbuffers.Offset, relation:Relation):flatbuffers.Offset {
  CommandRaceRelation.startCommandRaceRelation(builder);
  CommandRaceRelation.addAcceptor(builder, acceptorOffset);
  CommandRaceRelation.addRelation(builder, relation);
  return CommandRaceRelation.endCommandRaceRelation(builder);
}

unpack(): CommandRaceRelationT {
  return new CommandRaceRelationT(
    this.acceptor(),
    this.relation()
  );
}


unpackTo(_o: CommandRaceRelationT): void {
  _o.acceptor = this.acceptor();
  _o.relation = this.relation();
}
}

export class CommandRaceRelationT implements flatbuffers.IGeneratedObject {
constructor(
  public acceptor: string|Uint8Array|null = null,
  public relation: Relation = Relation.UNKNOWN
){}


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

  return CommandRaceRelation.createCommandRaceRelation(builder,
    acceptor,
    this.relation
  );
}
}
