// 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 { TechEntry, TechEntryT } from '../report/tech-entry.js';


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

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

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

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

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

tech(index: number, obj?:TechEntry):TechEntry|null {
  const offset = this.bb!.__offset(this.bb_pos, 8);
  return offset ? (obj || new TechEntry()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}

techLength():number {
  const offset = this.bb!.__offset(this.bb_pos, 8);
  return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}

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

load():number {
  const offset = this.bb!.__offset(this.bb_pos, 12);
  return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}

destination():bigint {
  const offset = this.bb!.__offset(this.bb_pos, 14);
  return offset ? this.bb!.readUint64(this.bb_pos + offset) : BigInt('0');
}

origin():bigint|null {
  const offset = this.bb!.__offset(this.bb_pos, 16);
  return offset ? this.bb!.readUint64(this.bb_pos + offset) : null;
}

range():number|null {
  const offset = this.bb!.__offset(this.bb_pos, 18);
  return offset ? this.bb!.readFloat32(this.bb_pos + offset) : null;
}

speed():number {
  const offset = this.bb!.__offset(this.bb_pos, 20);
  return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}

mass():number {
  const offset = this.bb!.__offset(this.bb_pos, 22);
  return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}

static startOtherGroup(builder:flatbuffers.Builder) {
  builder.startObject(10);
}

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

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

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

static createTechVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset {
  builder.startVector(4, data.length, 4);
  for (let i = data.length - 1; i >= 0; i--) {
    builder.addOffset(data[i]!);
  }
  return builder.endVector();
}

static startTechVector(builder:flatbuffers.Builder, numElems:number) {
  builder.startVector(4, numElems, 4);
}

static addCargo(builder:flatbuffers.Builder, cargoOffset:flatbuffers.Offset) {
  builder.addFieldOffset(3, cargoOffset, 0);
}

static addLoad(builder:flatbuffers.Builder, load:number) {
  builder.addFieldFloat32(4, load, 0.0);
}

static addDestination(builder:flatbuffers.Builder, destination:bigint) {
  builder.addFieldInt64(5, destination, BigInt('0'));
}

static addOrigin(builder:flatbuffers.Builder, origin:bigint) {
  builder.addFieldInt64(6, origin, null);
}

static addRange(builder:flatbuffers.Builder, range:number) {
  builder.addFieldFloat32(7, range, null);
}

static addSpeed(builder:flatbuffers.Builder, speed:number) {
  builder.addFieldFloat32(8, speed, 0.0);
}

static addMass(builder:flatbuffers.Builder, mass:number) {
  builder.addFieldFloat32(9, mass, 0.0);
}

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

static createOtherGroup(builder:flatbuffers.Builder, number:bigint, class_Offset:flatbuffers.Offset, techOffset:flatbuffers.Offset, cargoOffset:flatbuffers.Offset, load:number, destination:bigint, origin:bigint|null, range:number|null, speed:number, mass:number):flatbuffers.Offset {
  OtherGroup.startOtherGroup(builder);
  OtherGroup.addNumber(builder, number);
  OtherGroup.addClass(builder, class_Offset);
  OtherGroup.addTech(builder, techOffset);
  OtherGroup.addCargo(builder, cargoOffset);
  OtherGroup.addLoad(builder, load);
  OtherGroup.addDestination(builder, destination);
  if (origin !== null)
    OtherGroup.addOrigin(builder, origin);
  if (range !== null)
    OtherGroup.addRange(builder, range);
  OtherGroup.addSpeed(builder, speed);
  OtherGroup.addMass(builder, mass);
  return OtherGroup.endOtherGroup(builder);
}

unpack(): OtherGroupT {
  return new OtherGroupT(
    this.number(),
    this.class_(),
    this.bb!.createObjList<TechEntry, TechEntryT>(this.tech.bind(this), this.techLength()),
    this.cargo(),
    this.load(),
    this.destination(),
    this.origin(),
    this.range(),
    this.speed(),
    this.mass()
  );
}


unpackTo(_o: OtherGroupT): void {
  _o.number = this.number();
  _o.class_ = this.class_();
  _o.tech = this.bb!.createObjList<TechEntry, TechEntryT>(this.tech.bind(this), this.techLength());
  _o.cargo = this.cargo();
  _o.load = this.load();
  _o.destination = this.destination();
  _o.origin = this.origin();
  _o.range = this.range();
  _o.speed = this.speed();
  _o.mass = this.mass();
}
}

export class OtherGroupT implements flatbuffers.IGeneratedObject {
constructor(
  public number: bigint = BigInt('0'),
  public class_: string|Uint8Array|null = null,
  public tech: (TechEntryT)[] = [],
  public cargo: string|Uint8Array|null = null,
  public load: number = 0.0,
  public destination: bigint = BigInt('0'),
  public origin: bigint|null = null,
  public range: number|null = null,
  public speed: number = 0.0,
  public mass: number = 0.0
){}


pack(builder:flatbuffers.Builder): flatbuffers.Offset {
  const class_ = (this.class_ !== null ? builder.createString(this.class_!) : 0);
  const tech = OtherGroup.createTechVector(builder, builder.createObjectOffsetList(this.tech));
  const cargo = (this.cargo !== null ? builder.createString(this.cargo!) : 0);

  return OtherGroup.createOtherGroup(builder,
    this.number,
    class_,
    tech,
    cargo,
    this.load,
    this.destination,
    this.origin,
    this.range,
    this.speed,
    this.mass
  );
}
}
