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