// 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 { GameSummary, GameSummaryT } from '../lobby/game-summary.js';


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

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

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

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

static startGameCreateResponse(builder:flatbuffers.Builder) {
  builder.startObject(1);
}

static addGame(builder:flatbuffers.Builder, gameOffset:flatbuffers.Offset) {
  builder.addFieldOffset(0, gameOffset, 0);
}

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

static createGameCreateResponse(builder:flatbuffers.Builder, gameOffset:flatbuffers.Offset):flatbuffers.Offset {
  GameCreateResponse.startGameCreateResponse(builder);
  GameCreateResponse.addGame(builder, gameOffset);
  return GameCreateResponse.endGameCreateResponse(builder);
}

unpack(): GameCreateResponseT {
  return new GameCreateResponseT(
    (this.game() !== null ? this.game()!.unpack() : null)
  );
}


unpackTo(_o: GameCreateResponseT): void {
  _o.game = (this.game() !== null ? this.game()!.unpack() : null);
}
}

export class GameCreateResponseT implements flatbuffers.IGeneratedObject {
constructor(
  public game: GameSummaryT|null = null
){}


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

  return GameCreateResponse.createGameCreateResponse(builder,
    game
  );
}
}
