Files
OpenFrontIO/src/generated/game-updates/game-update-view-data.ts
T
2025-12-15 18:19:33 -08:00

230 lines
9.3 KiB
TypeScript

// 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 { GameUpdate, GameUpdateT } from '../game-updates/game-update.js';
import { NameViewData, NameViewDataT } from '../game-updates/name-view-data.js';
export class GameUpdateViewData implements flatbuffers.IUnpackableObject<GameUpdateViewDataT> {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):GameUpdateViewData {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsGameUpdateViewData(bb:flatbuffers.ByteBuffer, obj?:GameUpdateViewData):GameUpdateViewData {
return (obj || new GameUpdateViewData()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsGameUpdateViewData(bb:flatbuffers.ByteBuffer, obj?:GameUpdateViewData):GameUpdateViewData {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new GameUpdateViewData()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
tick():number {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0;
}
updates(index: number, obj?:GameUpdate):GameUpdate|null {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? (obj || new GameUpdate()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
updatesLength():number {
const offset = this.bb!.__offset(this.bb_pos, 6);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
packedTileUpdates(index: number):bigint|null {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.readUint64(this.bb!.__vector(this.bb_pos + offset) + index * 8) : BigInt(0);
}
packedTileUpdatesLength():number {
const offset = this.bb!.__offset(this.bb_pos, 8);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
playerNameViewDataKeys(index: number):string
playerNameViewDataKeys(index: number,optionalEncoding:flatbuffers.Encoding):string|Uint8Array
playerNameViewDataKeys(index: number,optionalEncoding?:any):string|Uint8Array|null {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.__string(this.bb!.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
}
playerNameViewDataKeysLength():number {
const offset = this.bb!.__offset(this.bb_pos, 10);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
playerNameViewDataValues(index: number, obj?:NameViewData):NameViewData|null {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? (obj || new NameViewData()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
}
playerNameViewDataValuesLength():number {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0;
}
tickExecutionDuration():number {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.readFloat32(this.bb_pos + offset) : 0.0;
}
static startGameUpdateViewData(builder:flatbuffers.Builder) {
builder.startObject(6);
}
static addTick(builder:flatbuffers.Builder, tick:number) {
builder.addFieldInt32(0, tick, 0);
}
static addUpdates(builder:flatbuffers.Builder, updatesOffset:flatbuffers.Offset) {
builder.addFieldOffset(1, updatesOffset, 0);
}
static createUpdatesVector(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 startUpdatesVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static addPackedTileUpdates(builder:flatbuffers.Builder, packedTileUpdatesOffset:flatbuffers.Offset) {
builder.addFieldOffset(2, packedTileUpdatesOffset, 0);
}
static createPackedTileUpdatesVector(builder:flatbuffers.Builder, data:bigint[]):flatbuffers.Offset {
builder.startVector(8, data.length, 8);
for (let i = data.length - 1; i >= 0; i--) {
builder.addInt64(data[i]!);
}
return builder.endVector();
}
static startPackedTileUpdatesVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(8, numElems, 8);
}
static addPlayerNameViewDataKeys(builder:flatbuffers.Builder, playerNameViewDataKeysOffset:flatbuffers.Offset) {
builder.addFieldOffset(3, playerNameViewDataKeysOffset, 0);
}
static createPlayerNameViewDataKeysVector(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 startPlayerNameViewDataKeysVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static addPlayerNameViewDataValues(builder:flatbuffers.Builder, playerNameViewDataValuesOffset:flatbuffers.Offset) {
builder.addFieldOffset(4, playerNameViewDataValuesOffset, 0);
}
static createPlayerNameViewDataValuesVector(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 startPlayerNameViewDataValuesVector(builder:flatbuffers.Builder, numElems:number) {
builder.startVector(4, numElems, 4);
}
static addTickExecutionDuration(builder:flatbuffers.Builder, tickExecutionDuration:number) {
builder.addFieldFloat32(5, tickExecutionDuration, 0.0);
}
static endGameUpdateViewData(builder:flatbuffers.Builder):flatbuffers.Offset {
const offset = builder.endObject();
return offset;
}
static finishGameUpdateViewDataBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
builder.finish(offset);
}
static finishSizePrefixedGameUpdateViewDataBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
builder.finish(offset, undefined, true);
}
static createGameUpdateViewData(builder:flatbuffers.Builder, tick:number, updatesOffset:flatbuffers.Offset, packedTileUpdatesOffset:flatbuffers.Offset, playerNameViewDataKeysOffset:flatbuffers.Offset, playerNameViewDataValuesOffset:flatbuffers.Offset, tickExecutionDuration:number):flatbuffers.Offset {
GameUpdateViewData.startGameUpdateViewData(builder);
GameUpdateViewData.addTick(builder, tick);
GameUpdateViewData.addUpdates(builder, updatesOffset);
GameUpdateViewData.addPackedTileUpdates(builder, packedTileUpdatesOffset);
GameUpdateViewData.addPlayerNameViewDataKeys(builder, playerNameViewDataKeysOffset);
GameUpdateViewData.addPlayerNameViewDataValues(builder, playerNameViewDataValuesOffset);
GameUpdateViewData.addTickExecutionDuration(builder, tickExecutionDuration);
return GameUpdateViewData.endGameUpdateViewData(builder);
}
unpack(): GameUpdateViewDataT {
return new GameUpdateViewDataT(
this.tick(),
this.bb!.createObjList<GameUpdate, GameUpdateT>(this.updates.bind(this), this.updatesLength()),
this.bb!.createScalarList<bigint>(this.packedTileUpdates.bind(this), this.packedTileUpdatesLength()),
this.bb!.createScalarList<string>(this.playerNameViewDataKeys.bind(this), this.playerNameViewDataKeysLength()),
this.bb!.createObjList<NameViewData, NameViewDataT>(this.playerNameViewDataValues.bind(this), this.playerNameViewDataValuesLength()),
this.tickExecutionDuration()
);
}
unpackTo(_o: GameUpdateViewDataT): void {
_o.tick = this.tick();
_o.updates = this.bb!.createObjList<GameUpdate, GameUpdateT>(this.updates.bind(this), this.updatesLength());
_o.packedTileUpdates = this.bb!.createScalarList<bigint>(this.packedTileUpdates.bind(this), this.packedTileUpdatesLength());
_o.playerNameViewDataKeys = this.bb!.createScalarList<string>(this.playerNameViewDataKeys.bind(this), this.playerNameViewDataKeysLength());
_o.playerNameViewDataValues = this.bb!.createObjList<NameViewData, NameViewDataT>(this.playerNameViewDataValues.bind(this), this.playerNameViewDataValuesLength());
_o.tickExecutionDuration = this.tickExecutionDuration();
}
}
export class GameUpdateViewDataT implements flatbuffers.IGeneratedObject {
constructor(
public tick: number = 0,
public updates: (GameUpdateT)[] = [],
public packedTileUpdates: (bigint)[] = [],
public playerNameViewDataKeys: (string)[] = [],
public playerNameViewDataValues: (NameViewDataT)[] = [],
public tickExecutionDuration: number = 0.0
){}
pack(builder:flatbuffers.Builder): flatbuffers.Offset {
const updates = GameUpdateViewData.createUpdatesVector(builder, builder.createObjectOffsetList(this.updates));
const packedTileUpdates = GameUpdateViewData.createPackedTileUpdatesVector(builder, this.packedTileUpdates);
const playerNameViewDataKeys = GameUpdateViewData.createPlayerNameViewDataKeysVector(builder, builder.createObjectOffsetList(this.playerNameViewDataKeys));
const playerNameViewDataValues = GameUpdateViewData.createPlayerNameViewDataValuesVector(builder, builder.createObjectOffsetList(this.playerNameViewDataValues));
return GameUpdateViewData.createGameUpdateViewData(builder,
this.tick,
updates,
packedTileUpdates,
playerNameViewDataKeys,
playerNameViewDataValues,
this.tickExecutionDuration
);
}
}