1--[[ Universe 2 3 Automatically generated by the FlatBuffers compiler, do not modify. 4 Or modify. I'm a message, not a cop. 5 6 flatc version: 23.5.26 7 8 Declared by : //basic.fbs 9 Rooting type : Universe (//basic.fbs) 10 11--]] 12 13local __Galaxy = require('Galaxy') 14local flatbuffers = require('flatbuffers') 15 16local Universe = {} 17local mt = {} 18 19function Universe.New() 20 local o = {} 21 setmetatable(o, {__index = mt}) 22 return o 23end 24 25function Universe.GetRootAsUniverse(buf, offset) 26 if type(buf) == "string" then 27 buf = flatbuffers.binaryArray.New(buf) 28 end 29 30 local n = flatbuffers.N.UOffsetT:Unpack(buf, offset) 31 local o = Universe.New() 32 o:Init(buf, n + offset) 33 return o 34end 35 36function mt:Init(buf, pos) 37 self.view = flatbuffers.view.New(buf, pos) 38end 39 40function mt:Age() 41 local o = self.view:Offset(4) 42 if o ~= 0 then 43 return self.view:Get(flatbuffers.N.Float64, self.view.pos + o) 44 end 45 return 0.0 46end 47 48function mt:Galaxies(j) 49 local o = self.view:Offset(6) 50 if o ~= 0 then 51 local x = self.view:Vector(o) 52 x = x + ((j-1) * 4) 53 x = self.view:Indirect(x) 54 local obj = __Galaxy.New() 55 obj:Init(self.view.bytes, x) 56 return obj 57 end 58end 59 60function mt:GalaxiesLength() 61 local o = self.view:Offset(6) 62 if o ~= 0 then 63 return self.view:VectorLen(o) 64 end 65 return 0 66end 67 68function Universe.Start(builder) 69 builder:StartObject(2) 70end 71 72function Universe.AddAge(builder, age) 73 builder:PrependFloat64Slot(0, age, 0.0) 74end 75 76function Universe.AddGalaxies(builder, galaxies) 77 builder:PrependUOffsetTRelativeSlot(1, galaxies, 0) 78end 79 80function Universe.StartGalaxiesVector(builder, numElems) 81 return builder:StartVector(4, numElems, 4) 82end 83 84function Universe.End(builder) 85 return builder:EndObject() 86end 87 88return Universe