summaryrefslogtreecommitdiff
path: root/tests/my-game/example/struct-of-structs.ts
blob: 11eca7ee5d0c29d70c6c24190a6c4268e7496dbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// automatically generated by the FlatBuffers compiler, do not modify

import * as flatbuffers from 'flatbuffers';

import { Ability, AbilityT } from '../../my-game/example/ability';
import { Test, TestT } from '../../my-game/example/test';


export class StructOfStructs {
  bb: flatbuffers.ByteBuffer|null = null;
  bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):StructOfStructs {
  this.bb_pos = i;
  this.bb = bb;
  return this;
}

a(obj?:Ability):Ability|null {
  return (obj || new Ability()).__init(this.bb_pos, this.bb!);
}

b(obj?:Test):Test|null {
  return (obj || new Test()).__init(this.bb_pos + 8, this.bb!);
}

c(obj?:Ability):Ability|null {
  return (obj || new Ability()).__init(this.bb_pos + 12, this.bb!);
}

static getFullyQualifiedName():string {
  return 'MyGame.Example.StructOfStructs';
}

static sizeOf():number {
  return 20;
}

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 {
  builder.prep(4, 20);
  builder.prep(4, 8);
  builder.writeInt32(c_distance);
  builder.writeInt32(c_id);
  builder.prep(2, 4);
  builder.pad(1);
  builder.writeInt8(b_b);
  builder.writeInt16(b_a);
  builder.prep(4, 8);
  builder.writeInt32(a_distance);
  builder.writeInt32(a_id);
  return builder.offset();
}


unpack(): StructOfStructsT {
  return new StructOfStructsT(
    (this.a() !== null ? this.a()!.unpack() : null),
    (this.b() !== null ? this.b()!.unpack() : null),
    (this.c() !== null ? this.c()!.unpack() : null)
  );
}


unpackTo(_o: StructOfStructsT): void {
  _o.a = (this.a() !== null ? this.a()!.unpack() : null);
  _o.b = (this.b() !== null ? this.b()!.unpack() : null);
  _o.c = (this.c() !== null ? this.c()!.unpack() : null);
}
}

export class StructOfStructsT {
constructor(
  public a: AbilityT|null = null,
  public b: TestT|null = null,
  public c: AbilityT|null = null
){}


pack(builder:flatbuffers.Builder): flatbuffers.Offset {
  return StructOfStructs.createStructOfStructs(builder,
    (this.a === null ? 0 : this.a.id!),
    (this.a === null ? 0 : this.a.distance!),
    (this.b === null ? 0 : this.b.a!),
    (this.b === null ? 0 : this.b.b!),
    (this.c === null ? 0 : this.c.id!),
    (this.c === null ? 0 : this.c.distance!)
  );
}
}