• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1-- automatically generated by the FlatBuffers compiler, do not modify
2
3-- namespace: Sample
4
5local flatbuffers = require('flatbuffers')
6
7local Monster = {} -- the module
8local Monster_mt = {} -- the class metatable
9
10function Monster.New()
11    local o = {}
12    setmetatable(o, {__index = Monster_mt})
13    return o
14end
15function Monster.GetRootAsMonster(buf, offset)
16    local n = flatbuffers.N.UOffsetT:Unpack(buf, offset)
17    local o = Monster.New()
18    o:Init(buf, n + offset)
19    return o
20end
21function Monster_mt:Init(buf, pos)
22    self.view = flatbuffers.view.New(buf, pos)
23end
24function Monster_mt:Pos()
25    local o = self.view:Offset(4)
26    if o ~= 0 then
27        local x = o + self.view.pos
28        local obj = require('MyGame.Sample.Vec3').New()
29        obj:Init(self.view.bytes, x)
30        return obj
31    end
32end
33function Monster_mt:Mana()
34    local o = self.view:Offset(6)
35    if o ~= 0 then
36        return self.view:Get(flatbuffers.N.Int16, o + self.view.pos)
37    end
38    return 150
39end
40function Monster_mt:Hp()
41    local o = self.view:Offset(8)
42    if o ~= 0 then
43        return self.view:Get(flatbuffers.N.Int16, o + self.view.pos)
44    end
45    return 100
46end
47function Monster_mt:Name()
48    local o = self.view:Offset(10)
49    if o ~= 0 then
50        return self.view:String(o + self.view.pos)
51    end
52end
53function Monster_mt:Inventory(j)
54    local o = self.view:Offset(14)
55    if o ~= 0 then
56        local a = self.view:Vector(o)
57        return self.view:Get(flatbuffers.N.Uint8, a + ((j-1) * 1))
58    end
59    return 0
60end
61function Monster_mt:InventoryLength()
62    local o = self.view:Offset(14)
63    if o ~= 0 then
64        return self.view:VectorLen(o)
65    end
66    return 0
67end
68function Monster_mt:Color()
69    local o = self.view:Offset(16)
70    if o ~= 0 then
71        return self.view:Get(flatbuffers.N.Int8, o + self.view.pos)
72    end
73    return 2
74end
75function Monster_mt:Weapons(j)
76    local o = self.view:Offset(18)
77    if o ~= 0 then
78        local x = self.view:Vector(o)
79        x = x + ((j-1) * 4)
80        x = self.view:Indirect(x)
81        local obj = require('MyGame.Sample.Weapon').New()
82        obj:Init(self.view.bytes, x)
83        return obj
84    end
85end
86function Monster_mt:WeaponsLength()
87    local o = self.view:Offset(18)
88    if o ~= 0 then
89        return self.view:VectorLen(o)
90    end
91    return 0
92end
93function Monster_mt:EquippedType()
94    local o = self.view:Offset(20)
95    if o ~= 0 then
96        return self.view:Get(flatbuffers.N.Uint8, o + self.view.pos)
97    end
98    return 0
99end
100function Monster_mt:Equipped()
101    local o = self.view:Offset(22)
102    if o ~= 0 then
103        local obj = flatbuffers.view.New(require('flatbuffers.binaryarray').New(0), 0)
104        self.view:Union(obj, o)
105        return obj
106    end
107end
108function Monster.Start(builder) builder:StartObject(10) end
109function Monster.AddPos(builder, pos) builder:PrependStructSlot(0, pos, 0) end
110function Monster.AddMana(builder, mana) builder:PrependInt16Slot(1, mana, 150) end
111function Monster.AddHp(builder, hp) builder:PrependInt16Slot(2, hp, 100) end
112function Monster.AddName(builder, name) builder:PrependUOffsetTRelativeSlot(3, name, 0) end
113function Monster.AddInventory(builder, inventory) builder:PrependUOffsetTRelativeSlot(5, inventory, 0) end
114function Monster.StartInventoryVector(builder, numElems) return builder:StartVector(1, numElems, 1) end
115function Monster.AddColor(builder, color) builder:PrependInt8Slot(6, color, 2) end
116function Monster.AddWeapons(builder, weapons) builder:PrependUOffsetTRelativeSlot(7, weapons, 0) end
117function Monster.StartWeaponsVector(builder, numElems) return builder:StartVector(4, numElems, 4) end
118function Monster.AddEquippedType(builder, equippedType) builder:PrependUint8Slot(8, equippedType, 0) end
119function Monster.AddEquipped(builder, equipped) builder:PrependUOffsetTRelativeSlot(9, equipped, 0) end
120function Monster.End(builder) return builder:EndObject() end
121
122return Monster -- return the module