• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// automatically generated by the FlatBuffers compiler, do not modify
2
3include "flatbuffers.lobster"
4
5namespace MyGame_Sample
6
7enum +
8    Color_Red = 0,
9    Color_Green = 1,
10    Color_Blue = 2
11
12enum +
13    Equipment_NONE = 0,
14    Equipment_Weapon = 1
15
16struct Vec3
17
18struct Monster
19
20struct Weapon
21
22struct Vec3 : flatbuffers_handle
23    def x():
24        buf_.read_float32_le(pos_ + 0)
25    def y():
26        buf_.read_float32_le(pos_ + 4)
27    def z():
28        buf_.read_float32_le(pos_ + 8)
29
30def CreateVec3(b_:flatbuffers_builder, x:float, y:float, z:float):
31    b_.Prep(4, 12)
32    b_.PrependFloat32(z)
33    b_.PrependFloat32(y)
34    b_.PrependFloat32(x)
35    return b_.Offset()
36
37struct Monster : flatbuffers_handle
38    def pos():
39        o := buf_.flatbuffers_field_struct(pos_, 4)
40        if o: MyGame_Sample_Vec3 { buf_, o } else: nil
41    def mana():
42        buf_.flatbuffers_field_int16(pos_, 6, 150)
43    def hp():
44        buf_.flatbuffers_field_int16(pos_, 8, 100)
45    def name():
46        buf_.flatbuffers_field_string(pos_, 10)
47    def inventory(i:int):
48        buf_.read_int8_le(buf_.flatbuffers_field_vector(pos_, 14) + i * 1)
49    def inventory_length():
50        buf_.flatbuffers_field_vector_len(pos_, 14)
51    def color():
52        buf_.flatbuffers_field_int8(pos_, 16, 2)
53    def weapons(i:int):
54        MyGame_Sample_Weapon { buf_, buf_.flatbuffers_indirect(buf_.flatbuffers_field_vector(pos_, 18) + i * 4) }
55    def weapons_length():
56        buf_.flatbuffers_field_vector_len(pos_, 18)
57    def equipped_type():
58        buf_.flatbuffers_field_int8(pos_, 20, 0)
59    def equipped_as_Weapon():
60        MyGame_Sample_Weapon { buf_, buf_.flatbuffers_field_table(pos_, 22) }
61
62def GetRootAsMonster(buf:string): Monster { buf, buf.flatbuffers_indirect(0) }
63
64def MonsterStart(b_:flatbuffers_builder):
65    b_.StartObject(10)
66def MonsterAddPos(b_:flatbuffers_builder, pos:int):
67    b_.PrependStructSlot(0, pos, 0)
68def MonsterAddMana(b_:flatbuffers_builder, mana:int):
69    b_.PrependInt16Slot(1, mana, 150)
70def MonsterAddHp(b_:flatbuffers_builder, hp:int):
71    b_.PrependInt16Slot(2, hp, 100)
72def MonsterAddName(b_:flatbuffers_builder, name:int):
73    b_.PrependUOffsetTRelativeSlot(3, name, 0)
74def MonsterAddInventory(b_:flatbuffers_builder, inventory:int):
75    b_.PrependUOffsetTRelativeSlot(5, inventory, 0)
76def MonsterStartInventoryVector(b_:flatbuffers_builder, n_:int):
77    b_.StartVector(1, n_, 1)
78def MonsterCreateInventoryVector(b_:flatbuffers_builder, v_:[int]):
79    b_.StartVector(1, v_.length, 1)
80    reverse(v_) e_: b_.PrependUint8(e_)
81    b_.EndVector(v_.length)
82def MonsterAddColor(b_:flatbuffers_builder, color:int):
83    b_.PrependInt8Slot(6, color, 2)
84def MonsterAddWeapons(b_:flatbuffers_builder, weapons:int):
85    b_.PrependUOffsetTRelativeSlot(7, weapons, 0)
86def MonsterStartWeaponsVector(b_:flatbuffers_builder, n_:int):
87    b_.StartVector(4, n_, 4)
88def MonsterCreateWeaponsVector(b_:flatbuffers_builder, v_:[int]):
89    b_.StartVector(4, v_.length, 4)
90    reverse(v_) e_: b_.PrependUOffsetTRelative(e_)
91    b_.EndVector(v_.length)
92def MonsterAddEquippedType(b_:flatbuffers_builder, equipped_type:int):
93    b_.PrependUint8Slot(8, equipped_type, 0)
94def MonsterAddEquipped(b_:flatbuffers_builder, equipped:int):
95    b_.PrependUOffsetTRelativeSlot(9, equipped, 0)
96def MonsterEnd(b_:flatbuffers_builder):
97    b_.EndObject()
98
99struct Weapon : flatbuffers_handle
100    def name():
101        buf_.flatbuffers_field_string(pos_, 4)
102    def damage():
103        buf_.flatbuffers_field_int16(pos_, 6, 0)
104
105def GetRootAsWeapon(buf:string): Weapon { buf, buf.flatbuffers_indirect(0) }
106
107def WeaponStart(b_:flatbuffers_builder):
108    b_.StartObject(2)
109def WeaponAddName(b_:flatbuffers_builder, name:int):
110    b_.PrependUOffsetTRelativeSlot(0, name, 0)
111def WeaponAddDamage(b_:flatbuffers_builder, damage:int):
112    b_.PrependInt16Slot(1, damage, 0)
113def WeaponEnd(b_:flatbuffers_builder):
114    b_.EndObject()
115
116