// 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 { ShipGroupCargo } from '../order/ship-group-cargo.js';


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

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

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

id():string|null
id(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
id(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;
}

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

quantity():number {
  const offset = this.bb!.__offset(this.bb_pos, 8);
  return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0;
}

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

static addId(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset) {
  builder.addFieldOffset(0, idOffset, 0);
}

static addCargo(builder:flatbuffers.Builder, cargo:ShipGroupCargo) {
  builder.addFieldInt8(1, cargo, ShipGroupCargo.UNKNOWN);
}

static addQuantity(builder:flatbuffers.Builder, quantity:number) {
  builder.addFieldFloat64(2, quantity, 0.0);
}

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

static createCommandShipGroupLoad(builder:flatbuffers.Builder, idOffset:flatbuffers.Offset, cargo:ShipGroupCargo, quantity:number):flatbuffers.Offset {
  CommandShipGroupLoad.startCommandShipGroupLoad(builder);
  CommandShipGroupLoad.addId(builder, idOffset);
  CommandShipGroupLoad.addCargo(builder, cargo);
  CommandShipGroupLoad.addQuantity(builder, quantity);
  return CommandShipGroupLoad.endCommandShipGroupLoad(builder);
}

unpack(): CommandShipGroupLoadT {
  return new CommandShipGroupLoadT(
    this.id(),
    this.cargo(),
    this.quantity()
  );
}


unpackTo(_o: CommandShipGroupLoadT): void {
  _o.id = this.id();
  _o.cargo = this.cargo();
  _o.quantity = this.quantity();
}
}

export class CommandShipGroupLoadT implements flatbuffers.IGeneratedObject {
constructor(
  public id: string|Uint8Array|null = null,
  public cargo: ShipGroupCargo = ShipGroupCargo.UNKNOWN,
  public quantity: number = 0.0
){}


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

  return CommandShipGroupLoad.createCommandShipGroupLoad(builder,
    id,
    this.cargo,
    this.quantity
  );
}
}
