• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // automatically generated by the FlatBuffers compiler, do not modify
2 // swiftlint:disable all
3 // swiftformat:disable all
4 
5 import FlatBuffers
6 
7 public enum MyGame_Sample_Color: Int8, Enum, Verifiable {
8   public typealias T = Int8
9   public static var byteSize: Int { return MemoryLayout<Int8>.size }
10   public var value: Int8 { return self.rawValue }
11   case red = 0
12   case green = 1
13   case blue = 2
14 
15   public static var max: MyGame_Sample_Color { return .blue }
16   public static var min: MyGame_Sample_Color { return .red }
17 }
18 
19 
20 public enum MyGame_Sample_Equipment: UInt8, UnionEnum {
21   public typealias T = UInt8
22 
23   public init?(value: T) {
24     self.init(rawValue: value)
25   }
26 
27   public static var byteSize: Int { return MemoryLayout<UInt8>.size }
28   public var value: UInt8 { return self.rawValue }
29   case none_ = 0
30   case weapon = 1
31 
32   public static var max: MyGame_Sample_Equipment { return .weapon }
33   public static var min: MyGame_Sample_Equipment { return .none_ }
34 }
35 
36 
37 public struct MyGame_Sample_Vec3: NativeStruct, Verifiable, FlatbuffersInitializable {
38 
validateVersionnull39   static func validateVersion() { FlatBuffersVersion_25_1_24() }
40 
41   private var _x: Float32
42   private var _y: Float32
43   private var _z: Float32
44 
45   public init(_ bb: ByteBuffer, o: Int32) {
46     let _accessor = Struct(bb: bb, position: o)
47     _x = _accessor.readBuffer(of: Float32.self, at: 0)
48     _y = _accessor.readBuffer(of: Float32.self, at: 4)
49     _z = _accessor.readBuffer(of: Float32.self, at: 8)
50   }
51 
52   public init(x: Float32, y: Float32, z: Float32) {
53     _x = x
54     _y = y
55     _z = z
56   }
57 
58   public init() {
59     _x = 0.0
60     _y = 0.0
61     _z = 0.0
62   }
63 
64   public var x: Float32 { _x }
65   public var y: Float32 { _y }
66   public var z: Float32 { _z }
67 
verify<T>null68   public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
69     try verifier.inBuffer(position: position, of: MyGame_Sample_Vec3.self)
70   }
71 }
72 
73 public struct MyGame_Sample_Vec3_Mutable: FlatBufferObject {
74 
validateVersionnull75   static func validateVersion() { FlatBuffersVersion_25_1_24() }
76   public var __buffer: ByteBuffer! { return _accessor.bb }
77   private var _accessor: Struct
78 
79   public init(_ bb: ByteBuffer, o: Int32) { _accessor = Struct(bb: bb, position: o) }
80 
81   public var x: Float32 { return _accessor.readBuffer(of: Float32.self, at: 0) }
mutatenull82   @discardableResult public func mutate(x: Float32) -> Bool { return _accessor.mutate(x, index: 0) }
83   public var y: Float32 { return _accessor.readBuffer(of: Float32.self, at: 4) }
mutatenull84   @discardableResult public func mutate(y: Float32) -> Bool { return _accessor.mutate(y, index: 4) }
85   public var z: Float32 { return _accessor.readBuffer(of: Float32.self, at: 8) }
mutatenull86   @discardableResult public func mutate(z: Float32) -> Bool { return _accessor.mutate(z, index: 8) }
87 }
88 
89 public struct MyGame_Sample_Monster: FlatBufferObject, Verifiable {
90 
validateVersionnull91   static func validateVersion() { FlatBuffersVersion_25_1_24() }
92   public var __buffer: ByteBuffer! { return _accessor.bb }
93   private var _accessor: Table
94 
95   private init(_ t: Table) { _accessor = t }
96   public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
97 
98   private enum VTOFFSET: VOffset {
99     case pos = 4
100     case mana = 6
101     case hp = 8
102     case name = 10
103     case inventory = 14
104     case color = 16
105     case weapons = 18
106     case equippedType = 20
107     case equipped = 22
108     case path = 24
109     var v: Int32 { Int32(self.rawValue) }
110     var p: VOffset { self.rawValue }
111   }
112 
113   public var pos: MyGame_Sample_Vec3? { let o = _accessor.offset(VTOFFSET.pos.v); return o == 0 ? nil : _accessor.readBuffer(of: MyGame_Sample_Vec3.self, at: o) }
114   public var mutablePos: MyGame_Sample_Vec3_Mutable? { let o = _accessor.offset(VTOFFSET.pos.v); return o == 0 ? nil : MyGame_Sample_Vec3_Mutable(_accessor.bb, o: o + _accessor.position) }
115   public var mana: Int16 { let o = _accessor.offset(VTOFFSET.mana.v); return o == 0 ? 150 : _accessor.readBuffer(of: Int16.self, at: o) }
mutatenull116   @discardableResult public func mutate(mana: Int16) -> Bool {let o = _accessor.offset(VTOFFSET.mana.v);  return _accessor.mutate(mana, index: o) }
117   public var hp: Int16 { let o = _accessor.offset(VTOFFSET.hp.v); return o == 0 ? 100 : _accessor.readBuffer(of: Int16.self, at: o) }
mutatenull118   @discardableResult public func mutate(hp: Int16) -> Bool {let o = _accessor.offset(VTOFFSET.hp.v);  return _accessor.mutate(hp, index: o) }
119   public var name: String? { let o = _accessor.offset(VTOFFSET.name.v); return o == 0 ? nil : _accessor.string(at: o) }
120   public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.name.v) }
121   public var hasInventory: Bool { let o = _accessor.offset(VTOFFSET.inventory.v); return o == 0 ? false : true }
122   public var inventoryCount: Int32 { let o = _accessor.offset(VTOFFSET.inventory.v); return o == 0 ? 0 : _accessor.vector(count: o) }
inventorynull123   public func inventory(at index: Int32) -> UInt8 { let o = _accessor.offset(VTOFFSET.inventory.v); return o == 0 ? 0 : _accessor.directRead(of: UInt8.self, offset: _accessor.vector(at: o) + index * 1) }
124   public var inventory: [UInt8] { return _accessor.getVector(at: VTOFFSET.inventory.v) ?? [] }
mutatenull125   public func mutate(inventory: UInt8, at index: Int32) -> Bool { let o = _accessor.offset(VTOFFSET.inventory.v); return _accessor.directMutate(inventory, index: _accessor.vector(at: o) + index * 1) }
126   public var color: MyGame_Sample_Color { let o = _accessor.offset(VTOFFSET.color.v); return o == 0 ? .blue : MyGame_Sample_Color(rawValue: _accessor.readBuffer(of: Int8.self, at: o)) ?? .blue }
mutatenull127   @discardableResult public func mutate(color: MyGame_Sample_Color) -> Bool {let o = _accessor.offset(VTOFFSET.color.v);  return _accessor.mutate(color.rawValue, index: o) }
128   public var hasWeapons: Bool { let o = _accessor.offset(VTOFFSET.weapons.v); return o == 0 ? false : true }
129   public var weaponsCount: Int32 { let o = _accessor.offset(VTOFFSET.weapons.v); return o == 0 ? 0 : _accessor.vector(count: o) }
weaponsnull130   public func weapons(at index: Int32) -> MyGame_Sample_Weapon? { let o = _accessor.offset(VTOFFSET.weapons.v); return o == 0 ? nil : MyGame_Sample_Weapon(_accessor.bb, o: _accessor.indirect(_accessor.vector(at: o) + index * 4)) }
131   public var equippedType: MyGame_Sample_Equipment { let o = _accessor.offset(VTOFFSET.equippedType.v); return o == 0 ? .none_ : MyGame_Sample_Equipment(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .none_ }
equipped<T: FlatbuffersInitializable>null132   public func equipped<T: FlatbuffersInitializable>(type: T.Type) -> T? { let o = _accessor.offset(VTOFFSET.equipped.v); return o == 0 ? nil : _accessor.union(o) }
133   public var hasPath: Bool { let o = _accessor.offset(VTOFFSET.path.v); return o == 0 ? false : true }
134   public var pathCount: Int32 { let o = _accessor.offset(VTOFFSET.path.v); return o == 0 ? 0 : _accessor.vector(count: o) }
pathnull135   public func path(at index: Int32) -> MyGame_Sample_Vec3? { let o = _accessor.offset(VTOFFSET.path.v); return o == 0 ? nil : _accessor.directRead(of: MyGame_Sample_Vec3.self, offset: _accessor.vector(at: o) + index * 12) }
mutablePathnull136   public func mutablePath(at index: Int32) -> MyGame_Sample_Vec3_Mutable? { let o = _accessor.offset(VTOFFSET.path.v); return o == 0 ? nil : MyGame_Sample_Vec3_Mutable(_accessor.bb, o: _accessor.vector(at: o) + index * 12) }
startMonsternull137   public static func startMonster(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 11) }
addnull138   public static func add(pos: MyGame_Sample_Vec3?, _ fbb: inout FlatBufferBuilder) { guard let pos = pos else { return }; fbb.create(struct: pos, position: VTOFFSET.pos.p) }
addnull139   public static func add(mana: Int16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: mana, def: 150, at: VTOFFSET.mana.p) }
addnull140   public static func add(hp: Int16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: hp, def: 100, at: VTOFFSET.hp.p) }
addnull141   public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: name, at: VTOFFSET.name.p) }
addVectorOfnull142   public static func addVectorOf(inventory: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: inventory, at: VTOFFSET.inventory.p) }
addnull143   public static func add(color: MyGame_Sample_Color, _ fbb: inout FlatBufferBuilder) { fbb.add(element: color.rawValue, def: 2, at: VTOFFSET.color.p) }
addVectorOfnull144   public static func addVectorOf(weapons: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: weapons, at: VTOFFSET.weapons.p) }
addnull145   public static func add(equippedType: MyGame_Sample_Equipment, _ fbb: inout FlatBufferBuilder) { fbb.add(element: equippedType.rawValue, def: 0, at: VTOFFSET.equippedType.p) }
addnull146   public static func add(equipped: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: equipped, at: VTOFFSET.equipped.p) }
addVectorOfnull147   public static func addVectorOf(path: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: path, at: VTOFFSET.path.p) }
startVectorOfPathnull148   public static func startVectorOfPath(_ size: Int, in builder: inout FlatBufferBuilder) {
149     builder.startVector(size * MemoryLayout<MyGame_Sample_Vec3>.size, elementSize: MemoryLayout<MyGame_Sample_Vec3>.alignment)
150   }
endMonsternull151   public static func endMonster(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
152   public static func createMonster(
153     _ fbb: inout FlatBufferBuilder,
154     pos: MyGame_Sample_Vec3? = nil,
155     mana: Int16 = 150,
156     hp: Int16 = 100,
157     nameOffset name: Offset = Offset(),
158     inventoryVectorOffset inventory: Offset = Offset(),
159     color: MyGame_Sample_Color = .blue,
160     weaponsVectorOffset weapons: Offset = Offset(),
161     equippedType: MyGame_Sample_Equipment = .none_,
162     equippedOffset equipped: Offset = Offset(),
163     pathVectorOffset path: Offset = Offset()
164   ) -> Offset {
165     let __start = MyGame_Sample_Monster.startMonster(&fbb)
166     MyGame_Sample_Monster.add(pos: pos, &fbb)
167     MyGame_Sample_Monster.add(mana: mana, &fbb)
168     MyGame_Sample_Monster.add(hp: hp, &fbb)
169     MyGame_Sample_Monster.add(name: name, &fbb)
170     MyGame_Sample_Monster.addVectorOf(inventory: inventory, &fbb)
171     MyGame_Sample_Monster.add(color: color, &fbb)
172     MyGame_Sample_Monster.addVectorOf(weapons: weapons, &fbb)
173     MyGame_Sample_Monster.add(equippedType: equippedType, &fbb)
174     MyGame_Sample_Monster.add(equipped: equipped, &fbb)
175     MyGame_Sample_Monster.addVectorOf(path: path, &fbb)
176     return MyGame_Sample_Monster.endMonster(&fbb, start: __start)
177   }
178 
verify<T>null179   public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
180     var _v = try verifier.visitTable(at: position)
181     try _v.visit(field: VTOFFSET.pos.p, fieldName: "pos", required: false, type: MyGame_Sample_Vec3.self)
182     try _v.visit(field: VTOFFSET.mana.p, fieldName: "mana", required: false, type: Int16.self)
183     try _v.visit(field: VTOFFSET.hp.p, fieldName: "hp", required: false, type: Int16.self)
184     try _v.visit(field: VTOFFSET.name.p, fieldName: "name", required: false, type: ForwardOffset<String>.self)
185     try _v.visit(field: VTOFFSET.inventory.p, fieldName: "inventory", required: false, type: ForwardOffset<Vector<UInt8, UInt8>>.self)
186     try _v.visit(field: VTOFFSET.color.p, fieldName: "color", required: false, type: MyGame_Sample_Color.self)
187     try _v.visit(field: VTOFFSET.weapons.p, fieldName: "weapons", required: false, type: ForwardOffset<Vector<ForwardOffset<MyGame_Sample_Weapon>, MyGame_Sample_Weapon>>.self)
188     try _v.visit(unionKey: VTOFFSET.equippedType.p, unionField: VTOFFSET.equipped.p, unionKeyName: "equippedType", fieldName: "equipped", required: false, completion: { (verifier, key: MyGame_Sample_Equipment, pos) in
189       switch key {
190       case .none_:
191         break // NOTE - SWIFT doesnt support none
192       case .weapon:
193         try ForwardOffset<MyGame_Sample_Weapon>.verify(&verifier, at: pos, of: MyGame_Sample_Weapon.self)
194       }
195     })
196     try _v.visit(field: VTOFFSET.path.p, fieldName: "path", required: false, type: ForwardOffset<Vector<MyGame_Sample_Vec3, MyGame_Sample_Vec3>>.self)
197     _v.finish()
198   }
199 }
200 
201 public struct MyGame_Sample_Weapon: FlatBufferObject, Verifiable {
202 
validateVersionnull203   static func validateVersion() { FlatBuffersVersion_25_1_24() }
204   public var __buffer: ByteBuffer! { return _accessor.bb }
205   private var _accessor: Table
206 
207   private init(_ t: Table) { _accessor = t }
208   public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
209 
210   private enum VTOFFSET: VOffset {
211     case name = 4
212     case damage = 6
213     var v: Int32 { Int32(self.rawValue) }
214     var p: VOffset { self.rawValue }
215   }
216 
217   public var name: String? { let o = _accessor.offset(VTOFFSET.name.v); return o == 0 ? nil : _accessor.string(at: o) }
218   public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.name.v) }
219   public var damage: Int16 { let o = _accessor.offset(VTOFFSET.damage.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int16.self, at: o) }
mutatenull220   @discardableResult public func mutate(damage: Int16) -> Bool {let o = _accessor.offset(VTOFFSET.damage.v);  return _accessor.mutate(damage, index: o) }
startWeaponnull221   public static func startWeapon(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 2) }
addnull222   public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: name, at: VTOFFSET.name.p) }
addnull223   public static func add(damage: Int16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: damage, def: 0, at: VTOFFSET.damage.p) }
endWeaponnull224   public static func endWeapon(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
225   public static func createWeapon(
226     _ fbb: inout FlatBufferBuilder,
227     nameOffset name: Offset = Offset(),
228     damage: Int16 = 0
229   ) -> Offset {
230     let __start = MyGame_Sample_Weapon.startWeapon(&fbb)
231     MyGame_Sample_Weapon.add(name: name, &fbb)
232     MyGame_Sample_Weapon.add(damage: damage, &fbb)
233     return MyGame_Sample_Weapon.endWeapon(&fbb, start: __start)
234   }
235 
verify<T>null236   public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
237     var _v = try verifier.visitTable(at: position)
238     try _v.visit(field: VTOFFSET.name.p, fieldName: "name", required: false, type: ForwardOffset<String>.self)
239     try _v.visit(field: VTOFFSET.damage.p, fieldName: "damage", required: false, type: Int16.self)
240     _v.finish()
241   }
242 }
243 
244