• 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 {
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 
16   public static var max: MyGame_Sample_Color { return .blue }
17   public static var min: MyGame_Sample_Color { return .red }
18 }
19 
20 public enum MyGame_Sample_Equipment: UInt8, Enum {
21   public typealias T = UInt8
22   public static var byteSize: Int { return MemoryLayout<UInt8>.size }
23   public var value: UInt8 { return self.rawValue }
24   case none_ = 0
25   case weapon = 1
26 
27 
28   public static var max: MyGame_Sample_Equipment { return .weapon }
29   public static var min: MyGame_Sample_Equipment { return .none_ }
30 }
31 
32 public struct MyGame_Sample_Vec3: NativeStruct {
33 
validateVersionnull34   static func validateVersion() { FlatBuffersVersion_2_0_0() }
35 
36   private var _x: Float32
37   private var _y: Float32
38   private var _z: Float32
39 
40   public init(x: Float32, y: Float32, z: Float32) {
41     _x = x
42     _y = y
43     _z = z
44   }
45 
46   public init() {
47     _x = 0.0
48     _y = 0.0
49     _z = 0.0
50   }
51 
52   public var x: Float32 { _x }
53   public var y: Float32 { _y }
54   public var z: Float32 { _z }
55 }
56 
57 public struct MyGame_Sample_Vec3_Mutable: FlatBufferObject {
58 
validateVersionnull59   static func validateVersion() { FlatBuffersVersion_2_0_0() }
60   public var __buffer: ByteBuffer! { return _accessor.bb }
61   private var _accessor: Struct
62 
63   public init(_ bb: ByteBuffer, o: Int32) { _accessor = Struct(bb: bb, position: o) }
64 
65   public var x: Float32 { return _accessor.readBuffer(of: Float32.self, at: 0) }
mutatenull66   @discardableResult public func mutate(x: Float32) -> Bool { return _accessor.mutate(x, index: 0) }
67   public var y: Float32 { return _accessor.readBuffer(of: Float32.self, at: 4) }
mutatenull68   @discardableResult public func mutate(y: Float32) -> Bool { return _accessor.mutate(y, index: 4) }
69   public var z: Float32 { return _accessor.readBuffer(of: Float32.self, at: 8) }
mutatenull70   @discardableResult public func mutate(z: Float32) -> Bool { return _accessor.mutate(z, index: 8) }
71 }
72 
73 public struct MyGame_Sample_Monster: FlatBufferObject {
74 
validateVersionnull75   static func validateVersion() { FlatBuffersVersion_2_0_0() }
76   public var __buffer: ByteBuffer! { return _accessor.bb }
77   private var _accessor: Table
78 
getRootAsMonsternull79   public static func getRootAsMonster(bb: ByteBuffer) -> MyGame_Sample_Monster { return MyGame_Sample_Monster(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
80 
81   private init(_ t: Table) { _accessor = t }
82   public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
83 
84   private enum VTOFFSET: VOffset {
85     case pos = 4
86     case mana = 6
87     case hp = 8
88     case name = 10
89     case inventory = 14
90     case color = 16
91     case weapons = 18
92     case equippedType = 20
93     case equipped = 22
94     case path = 24
95     var v: Int32 { Int32(self.rawValue) }
96     var p: VOffset { self.rawValue }
97   }
98 
99   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) }
100   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.postion) }
101   public var mana: Int16 { let o = _accessor.offset(VTOFFSET.mana.v); return o == 0 ? 150 : _accessor.readBuffer(of: Int16.self, at: o) }
mutatenull102   @discardableResult public func mutate(mana: Int16) -> Bool {let o = _accessor.offset(VTOFFSET.mana.v);  return _accessor.mutate(mana, index: o) }
103   public var hp: Int16 { let o = _accessor.offset(VTOFFSET.hp.v); return o == 0 ? 100 : _accessor.readBuffer(of: Int16.self, at: o) }
mutatenull104   @discardableResult public func mutate(hp: Int16) -> Bool {let o = _accessor.offset(VTOFFSET.hp.v);  return _accessor.mutate(hp, index: o) }
105   public var name: String? { let o = _accessor.offset(VTOFFSET.name.v); return o == 0 ? nil : _accessor.string(at: o) }
106   public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.name.v) }
107   public var inventoryCount: Int32 { let o = _accessor.offset(VTOFFSET.inventory.v); return o == 0 ? 0 : _accessor.vector(count: o) }
inventorynull108   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) }
109   public var inventory: [UInt8] { return _accessor.getVector(at: VTOFFSET.inventory.v) ?? [] }
mutatenull110   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) }
111   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 }
mutatenull112   @discardableResult public func mutate(color: MyGame_Sample_Color) -> Bool {let o = _accessor.offset(VTOFFSET.color.v);  return _accessor.mutate(color.rawValue, index: o) }
113   public var weaponsCount: Int32 { let o = _accessor.offset(VTOFFSET.weapons.v); return o == 0 ? 0 : _accessor.vector(count: o) }
weaponsnull114   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)) }
115   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>null116   public func equipped<T: FlatbuffersInitializable>(type: T.Type) -> T? { let o = _accessor.offset(VTOFFSET.equipped.v); return o == 0 ? nil : _accessor.union(o) }
117   public var pathCount: Int32 { let o = _accessor.offset(VTOFFSET.path.v); return o == 0 ? 0 : _accessor.vector(count: o) }
pathnull118   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) }
mutablePathnull119   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) }
startMonsternull120   public static func startMonster(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 11) }
addnull121   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) }
addnull122   public static func add(mana: Int16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: mana, def: 150, at: VTOFFSET.mana.p) }
addnull123   public static func add(hp: Int16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: hp, def: 100, at: VTOFFSET.hp.p) }
addnull124   public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: name, at: VTOFFSET.name.p) }
addVectorOfnull125   public static func addVectorOf(inventory: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: inventory, at: VTOFFSET.inventory.p) }
addnull126   public static func add(color: MyGame_Sample_Color, _ fbb: inout FlatBufferBuilder) { fbb.add(element: color.rawValue, def: 2, at: VTOFFSET.color.p) }
addVectorOfnull127   public static func addVectorOf(weapons: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: weapons, at: VTOFFSET.weapons.p) }
addnull128   public static func add(equippedType: MyGame_Sample_Equipment, _ fbb: inout FlatBufferBuilder) { fbb.add(element: equippedType.rawValue, def: 0, at: VTOFFSET.equippedType.p) }
addnull129   public static func add(equipped: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: equipped, at: VTOFFSET.equipped.p) }
addVectorOfnull130   public static func addVectorOf(path: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: path, at: VTOFFSET.path.p) }
startVectorOfPathnull131   public static func startVectorOfPath(_ size: Int, in builder: inout FlatBufferBuilder) {
132     builder.startVector(size * MemoryLayout<MyGame_Sample_Vec3>.size, elementSize: MemoryLayout<MyGame_Sample_Vec3>.alignment)
133   }
endMonsternull134   public static func endMonster(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
135   public static func createMonster(
136     _ fbb: inout FlatBufferBuilder,
137     pos: MyGame_Sample_Vec3? = nil,
138     mana: Int16 = 150,
139     hp: Int16 = 100,
140     nameOffset name: Offset = Offset(),
141     inventoryVectorOffset inventory: Offset = Offset(),
142     color: MyGame_Sample_Color = .blue,
143     weaponsVectorOffset weapons: Offset = Offset(),
144     equippedType: MyGame_Sample_Equipment = .none_,
145     equippedOffset equipped: Offset = Offset(),
146     pathVectorOffset path: Offset = Offset()
147   ) -> Offset {
148     let __start = MyGame_Sample_Monster.startMonster(&fbb)
149     MyGame_Sample_Monster.add(pos: pos, &fbb)
150     MyGame_Sample_Monster.add(mana: mana, &fbb)
151     MyGame_Sample_Monster.add(hp: hp, &fbb)
152     MyGame_Sample_Monster.add(name: name, &fbb)
153     MyGame_Sample_Monster.addVectorOf(inventory: inventory, &fbb)
154     MyGame_Sample_Monster.add(color: color, &fbb)
155     MyGame_Sample_Monster.addVectorOf(weapons: weapons, &fbb)
156     MyGame_Sample_Monster.add(equippedType: equippedType, &fbb)
157     MyGame_Sample_Monster.add(equipped: equipped, &fbb)
158     MyGame_Sample_Monster.addVectorOf(path: path, &fbb)
159     return MyGame_Sample_Monster.endMonster(&fbb, start: __start)
160   }
161 }
162 
163 public struct MyGame_Sample_Weapon: FlatBufferObject {
164 
validateVersionnull165   static func validateVersion() { FlatBuffersVersion_2_0_0() }
166   public var __buffer: ByteBuffer! { return _accessor.bb }
167   private var _accessor: Table
168 
getRootAsWeaponnull169   public static func getRootAsWeapon(bb: ByteBuffer) -> MyGame_Sample_Weapon { return MyGame_Sample_Weapon(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
170 
171   private init(_ t: Table) { _accessor = t }
172   public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
173 
174   private enum VTOFFSET: VOffset {
175     case name = 4
176     case damage = 6
177     var v: Int32 { Int32(self.rawValue) }
178     var p: VOffset { self.rawValue }
179   }
180 
181   public var name: String? { let o = _accessor.offset(VTOFFSET.name.v); return o == 0 ? nil : _accessor.string(at: o) }
182   public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.name.v) }
183   public var damage: Int16 { let o = _accessor.offset(VTOFFSET.damage.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int16.self, at: o) }
mutatenull184   @discardableResult public func mutate(damage: Int16) -> Bool {let o = _accessor.offset(VTOFFSET.damage.v);  return _accessor.mutate(damage, index: o) }
startWeaponnull185   public static func startWeapon(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 2) }
addnull186   public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: name, at: VTOFFSET.name.p) }
addnull187   public static func add(damage: Int16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: damage, def: 0, at: VTOFFSET.damage.p) }
endWeaponnull188   public static func endWeapon(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
189   public static func createWeapon(
190     _ fbb: inout FlatBufferBuilder,
191     nameOffset name: Offset = Offset(),
192     damage: Int16 = 0
193   ) -> Offset {
194     let __start = MyGame_Sample_Weapon.startWeapon(&fbb)
195     MyGame_Sample_Weapon.add(name: name, &fbb)
196     MyGame_Sample_Weapon.add(damage: damage, &fbb)
197     return MyGame_Sample_Weapon.endWeapon(&fbb, start: __start)
198   }
199 }
200 
201