Home | History | Annotate | Download | only in samples
      1 // automatically generated by the FlatBuffers compiler, do not modify
      2 
      3 include "flatbuffers.lobster"
      4 
      5 namespace MyGame_Sample
      6 
      7 enum + 
      8     Color_Red = 0,
      9     Color_Green = 1,
     10     Color_Blue = 2
     11 
     12 enum + 
     13     Equipment_NONE = 0,
     14     Equipment_Weapon = 1
     15 
     16 struct Vec3
     17 
     18 struct Monster
     19 
     20 struct Weapon
     21 
     22 struct 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 
     30 def 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 
     37 struct 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 
     62 def GetRootAsMonster(buf:string): Monster { buf, buf.flatbuffers_indirect(0) }
     63 
     64 def MonsterStart(b_:flatbuffers_builder):
     65     b_.StartObject(10)
     66 def MonsterAddPos(b_:flatbuffers_builder, pos:int):
     67     b_.PrependStructSlot(0, pos, 0)
     68 def MonsterAddMana(b_:flatbuffers_builder, mana:int):
     69     b_.PrependInt16Slot(1, mana, 150)
     70 def MonsterAddHp(b_:flatbuffers_builder, hp:int):
     71     b_.PrependInt16Slot(2, hp, 100)
     72 def MonsterAddName(b_:flatbuffers_builder, name:int):
     73     b_.PrependUOffsetTRelativeSlot(3, name, 0)
     74 def MonsterAddInventory(b_:flatbuffers_builder, inventory:int):
     75     b_.PrependUOffsetTRelativeSlot(5, inventory, 0)
     76 def MonsterStartInventoryVector(b_:flatbuffers_builder, n_:int):
     77     b_.StartVector(1, n_, 1)
     78 def 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)
     82 def MonsterAddColor(b_:flatbuffers_builder, color:int):
     83     b_.PrependInt8Slot(6, color, 2)
     84 def MonsterAddWeapons(b_:flatbuffers_builder, weapons:int):
     85     b_.PrependUOffsetTRelativeSlot(7, weapons, 0)
     86 def MonsterStartWeaponsVector(b_:flatbuffers_builder, n_:int):
     87     b_.StartVector(4, n_, 4)
     88 def 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)
     92 def MonsterAddEquippedType(b_:flatbuffers_builder, equipped_type:int):
     93     b_.PrependUint8Slot(8, equipped_type, 0)
     94 def MonsterAddEquipped(b_:flatbuffers_builder, equipped:int):
     95     b_.PrependUOffsetTRelativeSlot(9, equipped, 0)
     96 def MonsterEnd(b_:flatbuffers_builder):
     97     b_.EndObject()
     98 
     99 struct 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 
    105 def GetRootAsWeapon(buf:string): Weapon { buf, buf.flatbuffers_indirect(0) }
    106 
    107 def WeaponStart(b_:flatbuffers_builder):
    108     b_.StartObject(2)
    109 def WeaponAddName(b_:flatbuffers_builder, name:int):
    110     b_.PrependUOffsetTRelativeSlot(0, name, 0)
    111 def WeaponAddDamage(b_:flatbuffers_builder, damage:int):
    112     b_.PrependInt16Slot(1, damage, 0)
    113 def WeaponEnd(b_:flatbuffers_builder):
    114     b_.EndObject()
    115 
    116