// 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 { UserGamesOrder, UserGamesOrderT } from '../order/user-games-order.js';


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

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

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

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

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

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

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

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

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


unpack(): UserGamesOrderGetResponseT {
  return new UserGamesOrderGetResponseT(
    this.found(),
    (this.order() !== null ? this.order()!.unpack() : null)
  );
}


unpackTo(_o: UserGamesOrderGetResponseT): void {
  _o.found = this.found();
  _o.order = (this.order() !== null ? this.order()!.unpack() : null);
}
}

export class UserGamesOrderGetResponseT implements flatbuffers.IGeneratedObject {
constructor(
  public found: boolean = false,
  public order: UserGamesOrderT|null = null
){}


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

  UserGamesOrderGetResponse.startUserGamesOrderGetResponse(builder);
  UserGamesOrderGetResponse.addFound(builder, this.found);
  UserGamesOrderGetResponse.addOrder(builder, order);

  return UserGamesOrderGetResponse.endUserGamesOrderGetResponse(builder);
}
}
