1# automatically generated by the FlatBuffers compiler, do not modify
2
3# namespace: MyGame
4
5import flatbuffers
6from flatbuffers.compat import import_numpy
7np = import_numpy()
8
9class MonsterExtra(object):
10    __slots__ = ['_tab']
11
12    @classmethod
13    def GetRootAsMonsterExtra(cls, buf, offset):
14        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
15        x = MonsterExtra()
16        x.Init(buf, n + offset)
17        return x
18
19    @classmethod
20    def MonsterExtraBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
21        return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x4F\x4E\x45", size_prefixed=size_prefixed)
22
23    # MonsterExtra
24    def Init(self, buf, pos):
25        self._tab = flatbuffers.table.Table(buf, pos)
26
27    # MonsterExtra
28    def D0(self):
29        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
30        if o != 0:
31            return self._tab.Get(flatbuffers.number_types.Float64Flags, o + self._tab.Pos)
32        return float('nan')
33
34    # MonsterExtra
35    def D1(self):
36        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
37        if o != 0:
38            return self._tab.Get(flatbuffers.number_types.Float64Flags, o + self._tab.Pos)
39        return float('nan')
40
41    # MonsterExtra
42    def D2(self):
43        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
44        if o != 0:
45            return self._tab.Get(flatbuffers.number_types.Float64Flags, o + self._tab.Pos)
46        return float('inf')
47
48    # MonsterExtra
49    def D3(self):
50        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
51        if o != 0:
52            return self._tab.Get(flatbuffers.number_types.Float64Flags, o + self._tab.Pos)
53        return float('-inf')
54
55    # MonsterExtra
56    def F0(self):
57        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
58        if o != 0:
59            return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos)
60        return float('nan')
61
62    # MonsterExtra
63    def F1(self):
64        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
65        if o != 0:
66            return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos)
67        return float('nan')
68
69    # MonsterExtra
70    def F2(self):
71        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
72        if o != 0:
73            return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos)
74        return float('inf')
75
76    # MonsterExtra
77    def F3(self):
78        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
79        if o != 0:
80            return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos)
81        return float('-inf')
82
83    # MonsterExtra
84    def Dvec(self, j):
85        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20))
86        if o != 0:
87            a = self._tab.Vector(o)
88            return self._tab.Get(flatbuffers.number_types.Float64Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 8))
89        return 0
90
91    # MonsterExtra
92    def DvecAsNumpy(self):
93        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20))
94        if o != 0:
95            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Float64Flags, o)
96        return 0
97
98    # MonsterExtra
99    def DvecLength(self):
100        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20))
101        if o != 0:
102            return self._tab.VectorLen(o)
103        return 0
104
105    # MonsterExtra
106    def DvecIsNone(self):
107        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20))
108        return o == 0
109
110    # MonsterExtra
111    def Fvec(self, j):
112        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22))
113        if o != 0:
114            a = self._tab.Vector(o)
115            return self._tab.Get(flatbuffers.number_types.Float32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4))
116        return 0
117
118    # MonsterExtra
119    def FvecAsNumpy(self):
120        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22))
121        if o != 0:
122            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Float32Flags, o)
123        return 0
124
125    # MonsterExtra
126    def FvecLength(self):
127        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22))
128        if o != 0:
129            return self._tab.VectorLen(o)
130        return 0
131
132    # MonsterExtra
133    def FvecIsNone(self):
134        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22))
135        return o == 0
136
137def MonsterExtraStart(builder): builder.StartObject(11)
138def MonsterExtraAddD0(builder, d0): builder.PrependFloat64Slot(0, d0, float('nan'))
139def MonsterExtraAddD1(builder, d1): builder.PrependFloat64Slot(1, d1, float('nan'))
140def MonsterExtraAddD2(builder, d2): builder.PrependFloat64Slot(2, d2, float('inf'))
141def MonsterExtraAddD3(builder, d3): builder.PrependFloat64Slot(3, d3, float('-inf'))
142def MonsterExtraAddF0(builder, f0): builder.PrependFloat32Slot(4, f0, float('nan'))
143def MonsterExtraAddF1(builder, f1): builder.PrependFloat32Slot(5, f1, float('nan'))
144def MonsterExtraAddF2(builder, f2): builder.PrependFloat32Slot(6, f2, float('inf'))
145def MonsterExtraAddF3(builder, f3): builder.PrependFloat32Slot(7, f3, float('-inf'))
146def MonsterExtraAddDvec(builder, dvec): builder.PrependUOffsetTRelativeSlot(8, flatbuffers.number_types.UOffsetTFlags.py_type(dvec), 0)
147def MonsterExtraStartDvecVector(builder, numElems): return builder.StartVector(8, numElems, 8)
148def MonsterExtraAddFvec(builder, fvec): builder.PrependUOffsetTRelativeSlot(9, flatbuffers.number_types.UOffsetTFlags.py_type(fvec), 0)
149def MonsterExtraStartFvecVector(builder, numElems): return builder.StartVector(4, numElems, 4)
150def MonsterExtraEnd(builder): return builder.EndObject()
151
152try:
153    from typing import List
154except:
155    pass
156
157class MonsterExtraT(object):
158
159    # MonsterExtraT
160    def __init__(self):
161        self.d0 = float('nan')  # type: float
162        self.d1 = float('nan')  # type: float
163        self.d2 = float('inf')  # type: float
164        self.d3 = float('-inf')  # type: float
165        self.f0 = float('nan')  # type: float
166        self.f1 = float('nan')  # type: float
167        self.f2 = float('inf')  # type: float
168        self.f3 = float('-inf')  # type: float
169        self.dvec = None  # type: List[float]
170        self.fvec = None  # type: List[float]
171
172    @classmethod
173    def InitFromBuf(cls, buf, pos):
174        monsterExtra = MonsterExtra()
175        monsterExtra.Init(buf, pos)
176        return cls.InitFromObj(monsterExtra)
177
178    @classmethod
179    def InitFromObj(cls, monsterExtra):
180        x = MonsterExtraT()
181        x._UnPack(monsterExtra)
182        return x
183
184    # MonsterExtraT
185    def _UnPack(self, monsterExtra):
186        if monsterExtra is None:
187            return
188        self.d0 = monsterExtra.D0()
189        self.d1 = monsterExtra.D1()
190        self.d2 = monsterExtra.D2()
191        self.d3 = monsterExtra.D3()
192        self.f0 = monsterExtra.F0()
193        self.f1 = monsterExtra.F1()
194        self.f2 = monsterExtra.F2()
195        self.f3 = monsterExtra.F3()
196        if not monsterExtra.DvecIsNone():
197            if np is None:
198                self.dvec = []
199                for i in range(monsterExtra.DvecLength()):
200                    self.dvec.append(monsterExtra.Dvec(i))
201            else:
202                self.dvec = monsterExtra.DvecAsNumpy()
203        if not monsterExtra.FvecIsNone():
204            if np is None:
205                self.fvec = []
206                for i in range(monsterExtra.FvecLength()):
207                    self.fvec.append(monsterExtra.Fvec(i))
208            else:
209                self.fvec = monsterExtra.FvecAsNumpy()
210
211    # MonsterExtraT
212    def Pack(self, builder):
213        if self.dvec is not None:
214            if np is not None and type(self.dvec) is np.ndarray:
215                dvec = builder.CreateNumpyVector(self.dvec)
216            else:
217                MonsterExtraStartDvecVector(builder, len(self.dvec))
218                for i in reversed(range(len(self.dvec))):
219                    builder.PrependFloat64(self.dvec[i])
220                dvec = builder.EndVector(len(self.dvec))
221        if self.fvec is not None:
222            if np is not None and type(self.fvec) is np.ndarray:
223                fvec = builder.CreateNumpyVector(self.fvec)
224            else:
225                MonsterExtraStartFvecVector(builder, len(self.fvec))
226                for i in reversed(range(len(self.fvec))):
227                    builder.PrependFloat32(self.fvec[i])
228                fvec = builder.EndVector(len(self.fvec))
229        MonsterExtraStart(builder)
230        MonsterExtraAddD0(builder, self.d0)
231        MonsterExtraAddD1(builder, self.d1)
232        MonsterExtraAddD2(builder, self.d2)
233        MonsterExtraAddD3(builder, self.d3)
234        MonsterExtraAddF0(builder, self.f0)
235        MonsterExtraAddF1(builder, self.f1)
236        MonsterExtraAddF2(builder, self.f2)
237        MonsterExtraAddF3(builder, self.f3)
238        if self.dvec is not None:
239            MonsterExtraAddDvec(builder, dvec)
240        if self.fvec is not None:
241            MonsterExtraAddFvec(builder, fvec)
242        monsterExtra = MonsterExtraEnd(builder)
243        return monsterExtra
244