Debian Codegraph @

tests/ts/my-game/example/struct-of-structs.ts

raw
1 // automatically generated by the FlatBuffers compiler, do not modify
2
3 /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
4
5 import * as flatbuffers from 'flatbuffers';
6
7 import { Ability, AbilityT } from '../../my-game/example/ability.js';
8 import { Test, TestT } from '../../my-game/example/test.js';
9
10
11 export class StructOfStructs implements flatbuffers.IUnpackableObject<StructOfStructsT> {
12 bb: flatbuffers.ByteBuffer|null = null;
13 bb_pos = 0;
14 __init(i:number, bb:flatbuffers.ByteBuffer):StructOfStructs {
15 this.bb_pos = i;
16 this.bb = bb;
17 return this;
18 }
19
20 a(obj?:Ability):Ability|null {
21 return (obj || new Ability()).__init(this.bb_pos, this.bb!);
22 }
23
24 b(obj?:Test):Test|null {
25 return (obj || new Test()).__init(this.bb_pos + 8, this.bb!);
26 }
27
28 c(obj?:Ability):Ability|null {
29 return (obj || new Ability()).__init(this.bb_pos + 12, this.bb!);
30 }
31
32 static getFullyQualifiedName():string {
33 return 'MyGame.Example.StructOfStructs';
34 }
35
36 static sizeOf():number {
37 return 20;
38 }
39
40 static createStructOfStructs(builder:flatbuffers.Builder, a_id: number, a_distance: number, b_a: number, b_b: number, c_id: number, c_distance: number):flatbuffers.Offset {
41 builder.prep(4, 20);
42 builder.prep(4, 8);
43 builder.writeInt32(c_distance);
44 builder.writeInt32(c_id);
45 builder.prep(2, 4);
46 builder.pad(1);
47 builder.writeInt8(b_b);
48 builder.writeInt16(b_a);
49 builder.prep(4, 8);
50 builder.writeInt32(a_distance);
51 builder.writeInt32(a_id);
52 return builder.offset();
53 }
54
55
56 unpack(): StructOfStructsT {
57 return new StructOfStructsT(
58 (this.a() !== null ? this.a()!.unpack() : null),
59 (this.b() !== null ? this.b()!.unpack() : null),
60 (this.c() !== null ? this.c()!.unpack() : null)
61 );
62 }
63
64
65 unpackTo(_o: StructOfStructsT): void {
66 _o.a = (this.a() !== null ? this.a()!.unpack() : null);
67 _o.b = (this.b() !== null ? this.b()!.unpack() : null);
68 _o.c = (this.c() !== null ? this.c()!.unpack() : null);
69 }
70 }
71
72 export class StructOfStructsT implements flatbuffers.IGeneratedObject {
73 constructor(
74 public a: AbilityT|null = null,
75 public b: TestT|null = null,
76 public c: AbilityT|null = null
77 ){}
78
79
80 pack(builder:flatbuffers.Builder): flatbuffers.Offset {
81 return StructOfStructs.createStructOfStructs(builder,
82 (this.a?.id ?? 0),
83 (this.a?.distance ?? 0),
84 (this.b?.a ?? 0),
85 (this.b?.b ?? 0),
86 (this.c?.id ?? 0),
87 (this.c?.distance ?? 0)
88 );
89 }
90 }