# automatically generated by the FlatBuffers compiler, do not modify

# namespace: Types

import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()

class Vector2(object):
    __slots__ = ['_tab']

    @classmethod
    def SizeOf(cls):
        return 8

    # Vector2
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

    # Vector2
    def X(self): return self._tab.Get(flatbuffers.number_types.Float32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(0))
    # Vector2
    def Y(self): return self._tab.Get(flatbuffers.number_types.Float32Flags, self._tab.Pos + flatbuffers.number_types.UOffsetTFlags.py_type(4))

def CreateVector2(builder, x, y):
    builder.Prep(4, 8)
    builder.PrependFloat32(y)
    builder.PrependFloat32(x)
    return builder.Offset()


class Vector2T(object):

    # Vector2T
    def __init__(self):
        self.x = 0.0  # type: float
        self.y = 0.0  # type: float

    @classmethod
    def InitFromBuf(cls, buf, pos):
        vector2 = Vector2()
        vector2.Init(buf, pos)
        return cls.InitFromObj(vector2)

    @classmethod
    def InitFromPackedBuf(cls, buf, pos=0):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
        return cls.InitFromBuf(buf, pos+n)

    @classmethod
    def InitFromObj(cls, vector2):
        x = Vector2T()
        x._UnPack(vector2)
        return x

    # Vector2T
    def _UnPack(self, vector2):
        if vector2 is None:
            return
        self.x = vector2.X()
        self.y = vector2.Y()

    # Vector2T
    def Pack(self, builder):
        return CreateVector2(builder, self.x, self.y)
