Debian Codegraph @

tests/ts/my-game/example/vec3.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 { Color } from '../../my-game/example/color.js';
8 import { Test, TestT } from '../../my-game/example/test.js';
9
10
11 export class Vec3 implements flatbuffers.IUnpackableObject<Vec3T> {
12 bb: flatbuffers.ByteBuffer|null = null;
13 bb_pos = 0;
14 __init(i:number, bb:flatbuffers.ByteBuffer):Vec3 {
15 this.bb_pos = i;
16 this.bb = bb;
17 return this;
18 }
19
20 x():number {
21 return this.bb!.readFloat32(this.bb_pos);
22 }
23
24 mutate_x(value:number):boolean {
25 this.bb!.writeFloat32(this.bb_pos + 0, value);
26 return true;
27 }
28
29 y():number {
30 return this.bb!.readFloat32(this.bb_pos + 4);
31 }
32
33 mutate_y(value:number):boolean {
34 this.bb!.writeFloat32(this.bb_pos + 4, value);
35 return true;
36 }
37
38 z():number {
39 return this.bb!.readFloat32(this.bb_pos + 8);
40 }
41
42 mutate_z(value:number):boolean {
43 this.bb!.writeFloat32(this.bb_pos + 8, value);
44 return true;
45 }
46
47 test1():number {
48 return this.bb!.readFloat64(this.bb_pos + 16);
49 }
50
51 mutate_test1(value:number):boolean {
52 this.bb!.writeFloat64(this.bb_pos + 16, value);
53 return true;
54 }
55
56 test2():Color {
57 return this.bb!.readUint8(this.bb_pos + 24);
58 }
59
60 mutate_test2(value:Color):boolean {
61 this.bb!.writeUint8(this.bb_pos + 24, value);
62 return true;
63 }
64
65 test3(obj?:Test):Test|null {
66 return (obj || new Test()).__init(this.bb_pos + 26, this.bb!);
67 }
68
69 static getFullyQualifiedName():string {
70 return 'MyGame.Example.Vec3';
71 }
72
73 static sizeOf():number {
74 return 32;
75 }
76
77 static createVec3(builder:flatbuffers.Builder, x: number, y: number, z: number, test1: number, test2: Color, test3_a: number, test3_b: number):flatbuffers.Offset {
78 builder.prep(8, 32);
79 builder.pad(2);
80 builder.prep(2, 4);
81 builder.pad(1);
82 builder.writeInt8(test3_b);
83 builder.writeInt16(test3_a);
84 builder.pad(1);
85 builder.writeInt8(test2);
86 builder.writeFloat64(test1);
87 builder.pad(4);
88 builder.writeFloat32(z);
89 builder.writeFloat32(y);
90 builder.writeFloat32(x);
91 return builder.offset();
92 }
93
94
95 unpack(): Vec3T {
96 return new Vec3T(
97 this.x(),
98 this.y(),
99 this.z(),
100 this.test1(),
101 this.test2(),
102 (this.test3() !== null ? this.test3()!.unpack() : null)
103 );
104 }
105
106
107 unpackTo(_o: Vec3T): void {
108 _o.x = this.x();
109 _o.y = this.y();
110 _o.z = this.z();
111 _o.test1 = this.test1();
112 _o.test2 = this.test2();
113 _o.test3 = (this.test3() !== null ? this.test3()!.unpack() : null);
114 }
115 }
116
117 export class Vec3T implements flatbuffers.IGeneratedObject {
118 constructor(
119 public x: number = 0.0,
120 public y: number = 0.0,
121 public z: number = 0.0,
122 public test1: number = 0.0,
123 public test2: Color = Color.Red,
124 public test3: TestT|null = null
125 ){}
126
127
128 pack(builder:flatbuffers.Builder): flatbuffers.Offset {
129 return Vec3.createVec3(builder,
130 this.x,
131 this.y,
132 this.z,
133 this.test1,
134 this.test2,
135 (this.test3?.a ?? 0),
136 (this.test3?.b ?? 0)
137 );
138 }
139 }