// 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 Player implements flatbuffers.IUnpackableObject<PlayerT> {
  bb: flatbuffers.ByteBuffer|null = null;
  bb_pos = 0;
  __init(i:number, bb:flatbuffers.ByteBuffer):Player {
  this.bb_pos = i;
  this.bb = bb;
  return this;
}

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

static getSizePrefixedRootAsPlayer(bb:flatbuffers.ByteBuffer, obj?:Player):Player {
  bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
  return (obj || new Player()).__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;
}

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

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

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

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

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

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

planets():number {
  const offset = this.bb!.__offset(this.bb_pos, 18);
  return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
}

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

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

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

static startPlayer(builder:flatbuffers.Builder) {
  builder.startObject(11);
}

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

static addDrive(builder:flatbuffers.Builder, drive:number) {
  builder.addFieldFloat32(1, drive, 0.0);
}

static addWeapons(builder:flatbuffers.Builder, weapons:number) {
  builder.addFieldFloat32(2, weapons, 0.0);
}

static addShields(builder:flatbuffers.Builder, shields:number) {
  builder.addFieldFloat32(3, shields, 0.0);
}

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

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

static addIndustry(builder:flatbuffers.Builder, industry:number) {
  builder.addFieldFloat32(6, industry, 0.0);
}

static addPlanets(builder:flatbuffers.Builder, planets:number) {
  builder.addFieldInt16(7, planets, 0);
}

static addRelation(builder:flatbuffers.Builder, relationOffset:flatbuffers.Offset) {
  builder.addFieldOffset(8, relationOffset, 0);
}

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

static addExtinct(builder:flatbuffers.Builder, extinct:boolean) {
  builder.addFieldInt8(10, +extinct, +false);
}

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

static createPlayer(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset, drive:number, weapons:number, shields:number, cargo:number, population:number, industry:number, planets:number, relationOffset:flatbuffers.Offset, votes:number, extinct:boolean):flatbuffers.Offset {
  Player.startPlayer(builder);
  Player.addName(builder, nameOffset);
  Player.addDrive(builder, drive);
  Player.addWeapons(builder, weapons);
  Player.addShields(builder, shields);
  Player.addCargo(builder, cargo);
  Player.addPopulation(builder, population);
  Player.addIndustry(builder, industry);
  Player.addPlanets(builder, planets);
  Player.addRelation(builder, relationOffset);
  Player.addVotes(builder, votes);
  Player.addExtinct(builder, extinct);
  return Player.endPlayer(builder);
}

unpack(): PlayerT {
  return new PlayerT(
    this.name(),
    this.drive(),
    this.weapons(),
    this.shields(),
    this.cargo(),
    this.population(),
    this.industry(),
    this.planets(),
    this.relation(),
    this.votes(),
    this.extinct()
  );
}


unpackTo(_o: PlayerT): void {
  _o.name = this.name();
  _o.drive = this.drive();
  _o.weapons = this.weapons();
  _o.shields = this.shields();
  _o.cargo = this.cargo();
  _o.population = this.population();
  _o.industry = this.industry();
  _o.planets = this.planets();
  _o.relation = this.relation();
  _o.votes = this.votes();
  _o.extinct = this.extinct();
}
}

export class PlayerT implements flatbuffers.IGeneratedObject {
constructor(
  public name: string|Uint8Array|null = null,
  public drive: number = 0.0,
  public weapons: number = 0.0,
  public shields: number = 0.0,
  public cargo: number = 0.0,
  public population: number = 0.0,
  public industry: number = 0.0,
  public planets: number = 0,
  public relation: string|Uint8Array|null = null,
  public votes: number = 0.0,
  public extinct: boolean = false
){}


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

  return Player.createPlayer(builder,
    name,
    this.drive,
    this.weapons,
    this.shields,
    this.cargo,
    this.population,
    this.industry,
    this.planets,
    relation,
    this.votes,
    this.extinct
  );
}
}
