// automatically generated by the FlatBuffers compiler, do not modify

import * as flatbuffers from 'flatbuffers';

import { FeedbackReply } from '../scrabblefb/feedback-reply.js';


export class FeedbackState {
  bb: flatbuffers.ByteBuffer|null = null;
  bb_pos = 0;
  __init(i:number, bb:flatbuffers.ByteBuffer):FeedbackState {
  this.bb_pos = i;
  this.bb = bb;
  return this;
}

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

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

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

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

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

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

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

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

static addReply(builder:flatbuffers.Builder, replyOffset:flatbuffers.Offset) {
  builder.addFieldOffset(2, replyOffset, 0);
}

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

}
