Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 1 | // automatically generated by the FlatBuffers compiler, do not modify |
| 2 | import flatbuffers |
| 3 | |
| 4 | namespace MyGame_Sample |
| 5 | |
| 6 | enum Color: |
| 7 | Color_Red = 0 |
| 8 | Color_Green = 1 |
| 9 | Color_Blue = 2 |
| 10 | |
| 11 | enum Equipment: |
| 12 | Equipment_NONE = 0 |
| 13 | Equipment_Weapon = 1 |
| 14 | |
| 15 | class Vec3 |
| 16 | |
| 17 | class Monster |
| 18 | |
| 19 | class Weapon |
| 20 | |
| 21 | class Vec3 : flatbuffers_handle |
| 22 | def x(): |
| 23 | return buf_.read_float32_le(pos_ + 0) |
| 24 | def y(): |
| 25 | return buf_.read_float32_le(pos_ + 4) |
| 26 | def z(): |
| 27 | return buf_.read_float32_le(pos_ + 8) |
| 28 | |
| 29 | def CreateVec3(b_:flatbuffers_builder, x:float, y:float, z:float): |
| 30 | b_.Prep(4, 12) |
| 31 | b_.PrependFloat32(z) |
| 32 | b_.PrependFloat32(y) |
| 33 | b_.PrependFloat32(x) |
| 34 | return b_.Offset() |
| 35 | |
| 36 | class Monster : flatbuffers_handle |
| 37 | def pos(): |
| 38 | let o = buf_.flatbuffers_field_struct(pos_, 4) |
| 39 | return if o: MyGame_Sample_Vec3 { buf_, o } else: nil |
| 40 | def mana(): |
| 41 | return buf_.flatbuffers_field_int16(pos_, 6, 150) |
| 42 | def hp(): |
| 43 | return buf_.flatbuffers_field_int16(pos_, 8, 100) |
| 44 | def name(): |
| 45 | return buf_.flatbuffers_field_string(pos_, 10) |
| 46 | def inventory(i:int): |
| 47 | return buf_.read_int8_le(buf_.flatbuffers_field_vector(pos_, 14) + i * 1) |
| 48 | def inventory_length(): |
| 49 | return buf_.flatbuffers_field_vector_len(pos_, 14) |
| 50 | def color(): |
| 51 | return Color(buf_.flatbuffers_field_int8(pos_, 16, 2)) |
| 52 | def weapons(i:int): |
| 53 | return MyGame_Sample_Weapon { buf_, buf_.flatbuffers_indirect(buf_.flatbuffers_field_vector(pos_, 18) + i * 4) } |
| 54 | def weapons_length(): |
| 55 | return buf_.flatbuffers_field_vector_len(pos_, 18) |
| 56 | def equipped_type(): |
| 57 | return Equipment(buf_.flatbuffers_field_int8(pos_, 20, 0)) |
| 58 | def equipped_as_Weapon(): |
| 59 | return MyGame_Sample_Weapon { buf_, buf_.flatbuffers_field_table(pos_, 22) } |
| 60 | def path(i:int): |
| 61 | return MyGame_Sample_Vec3 { buf_, buf_.flatbuffers_field_vector(pos_, 24) + i * 12 } |
| 62 | def path_length(): |
| 63 | return buf_.flatbuffers_field_vector_len(pos_, 24) |
| 64 | |
| 65 | def GetRootAsMonster(buf:string): return Monster { buf, buf.flatbuffers_indirect(0) } |
| 66 | |
| 67 | struct MonsterBuilder: |
| 68 | b_:flatbuffers_builder |
| 69 | def start(): |
| 70 | b_.StartObject(11) |
| 71 | return this |
| 72 | def add_pos(pos:flatbuffers_offset): |
| 73 | b_.PrependStructSlot(0, pos) |
| 74 | return this |
| 75 | def add_mana(mana:int): |
| 76 | b_.PrependInt16Slot(1, mana, 150) |
| 77 | return this |
| 78 | def add_hp(hp:int): |
| 79 | b_.PrependInt16Slot(2, hp, 100) |
| 80 | return this |
| 81 | def add_name(name:flatbuffers_offset): |
| 82 | b_.PrependUOffsetTRelativeSlot(3, name) |
| 83 | return this |
| 84 | def add_inventory(inventory:flatbuffers_offset): |
| 85 | b_.PrependUOffsetTRelativeSlot(5, inventory) |
| 86 | return this |
| 87 | def add_color(color:Color): |
| 88 | b_.PrependInt8Slot(6, color, 2) |
| 89 | return this |
| 90 | def add_weapons(weapons:flatbuffers_offset): |
| 91 | b_.PrependUOffsetTRelativeSlot(7, weapons) |
| 92 | return this |
| 93 | def add_equipped_type(equipped_type:Equipment): |
| 94 | b_.PrependUint8Slot(8, equipped_type, 0) |
| 95 | return this |
| 96 | def add_equipped(equipped:flatbuffers_offset): |
| 97 | b_.PrependUOffsetTRelativeSlot(9, equipped) |
| 98 | return this |
| 99 | def add_path(path:flatbuffers_offset): |
| 100 | b_.PrependUOffsetTRelativeSlot(10, path) |
| 101 | return this |
| 102 | def end(): |
| 103 | return b_.EndObject() |
| 104 | |
| 105 | def MonsterStartInventoryVector(b_:flatbuffers_builder, n_:int): |
| 106 | b_.StartVector(1, n_, 1) |
| 107 | def MonsterCreateInventoryVector(b_:flatbuffers_builder, v_:[int]): |
| 108 | b_.StartVector(1, v_.length, 1) |
| 109 | reverse(v_) e_: b_.PrependUint8(e_) |
| 110 | return b_.EndVector(v_.length) |
| 111 | |
| 112 | def MonsterStartWeaponsVector(b_:flatbuffers_builder, n_:int): |
| 113 | b_.StartVector(4, n_, 4) |
| 114 | def MonsterCreateWeaponsVector(b_:flatbuffers_builder, v_:[flatbuffers_offset]): |
| 115 | b_.StartVector(4, v_.length, 4) |
| 116 | reverse(v_) e_: b_.PrependUOffsetTRelative(e_) |
| 117 | return b_.EndVector(v_.length) |
| 118 | |
| 119 | def MonsterStartPathVector(b_:flatbuffers_builder, n_:int): |
| 120 | b_.StartVector(12, n_, 4) |
| 121 | |
| 122 | class Weapon : flatbuffers_handle |
| 123 | def name(): |
| 124 | return buf_.flatbuffers_field_string(pos_, 4) |
| 125 | def damage(): |
| 126 | return buf_.flatbuffers_field_int16(pos_, 6, 0) |
| 127 | |
| 128 | def GetRootAsWeapon(buf:string): return Weapon { buf, buf.flatbuffers_indirect(0) } |
| 129 | |
| 130 | struct WeaponBuilder: |
| 131 | b_:flatbuffers_builder |
| 132 | def start(): |
| 133 | b_.StartObject(2) |
| 134 | return this |
| 135 | def add_name(name:flatbuffers_offset): |
| 136 | b_.PrependUOffsetTRelativeSlot(0, name) |
| 137 | return this |
| 138 | def add_damage(damage:int): |
| 139 | b_.PrependInt16Slot(1, damage, 0) |
| 140 | return this |
| 141 | def end(): |
| 142 | return b_.EndObject() |
| 143 | |