// 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 { PlanetProduction } from '../order/planet-production.js';


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

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

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

number():bigint {
  const offset = this.bb!.__offset(this.bb_pos, 4);
  return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
}

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

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

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

static addNumber(builder:flatbuffers.Builder, number:bigint) {
  builder.addFieldInt64(0, number, BigInt('0'));
}

static addProduction(builder:flatbuffers.Builder, production:PlanetProduction) {
  builder.addFieldInt8(1, production, PlanetProduction.UNKNOWN);
}

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

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

static createCommandPlanetProduce(builder:flatbuffers.Builder, number:bigint, production:PlanetProduction, subjectOffset:flatbuffers.Offset):flatbuffers.Offset {
  CommandPlanetProduce.startCommandPlanetProduce(builder);
  CommandPlanetProduce.addNumber(builder, number);
  CommandPlanetProduce.addProduction(builder, production);
  CommandPlanetProduce.addSubject(builder, subjectOffset);
  return CommandPlanetProduce.endCommandPlanetProduce(builder);
}

unpack(): CommandPlanetProduceT {
  return new CommandPlanetProduceT(
    this.number(),
    this.production(),
    this.subject()
  );
}


unpackTo(_o: CommandPlanetProduceT): void {
  _o.number = this.number();
  _o.production = this.production();
  _o.subject = this.subject();
}
}

export class CommandPlanetProduceT implements flatbuffers.IGeneratedObject {
constructor(
  public number: bigint = BigInt('0'),
  public production: PlanetProduction = PlanetProduction.UNKNOWN,
  public subject: string|Uint8Array|null = null
){}


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

  return CommandPlanetProduce.createCommandPlanetProduce(builder,
    this.number,
    this.production,
    subject
  );
}
}
