// 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';



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

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

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

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

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

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

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

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

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

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

static startLocalFleet(builder:flatbuffers.Builder) {
  builder.startObject(7);
}

static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) {
  builder.addFieldOffset(0, nameOffset, 0);
}

static addGroups(builder:flatbuffers.Builder, groups:bigint) {
  builder.addFieldInt64(1, groups, BigInt('0'));
}

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

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

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

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

static addState(builder:flatbuffers.Builder, stateOffset:flatbuffers.Offset) {
  builder.addFieldOffset(6, stateOffset, 0);
}

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

static createLocalFleet(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset, groups:bigint, destination:bigint, origin:bigint|null, range:number|null, speed:number, stateOffset:flatbuffers.Offset):flatbuffers.Offset {
  LocalFleet.startLocalFleet(builder);
  LocalFleet.addName(builder, nameOffset);
  LocalFleet.addGroups(builder, groups);
  LocalFleet.addDestination(builder, destination);
  if (origin !== null)
    LocalFleet.addOrigin(builder, origin);
  if (range !== null)
    LocalFleet.addRange(builder, range);
  LocalFleet.addSpeed(builder, speed);
  LocalFleet.addState(builder, stateOffset);
  return LocalFleet.endLocalFleet(builder);
}

unpack(): LocalFleetT {
  return new LocalFleetT(
    this.name(),
    this.groups(),
    this.destination(),
    this.origin(),
    this.range(),
    this.speed(),
    this.state()
  );
}


unpackTo(_o: LocalFleetT): void {
  _o.name = this.name();
  _o.groups = this.groups();
  _o.destination = this.destination();
  _o.origin = this.origin();
  _o.range = this.range();
  _o.speed = this.speed();
  _o.state = this.state();
}
}

export class LocalFleetT implements flatbuffers.IGeneratedObject {
constructor(
  public name: string|Uint8Array|null = null,
  public groups: bigint = BigInt('0'),
  public destination: bigint = BigInt('0'),
  public origin: bigint|null = null,
  public range: number|null = null,
  public speed: number = 0.0,
  public state: string|Uint8Array|null = null
){}


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

  return LocalFleet.createLocalFleet(builder,
    name,
    this.groups,
    this.destination,
    this.origin,
    this.range,
    this.speed,
    state
  );
}
}
