# automatically generated by the FlatBuffers compiler, do not modify

# namespace: Packets

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

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

    @classmethod
    def GetRootAs(cls, buf, offset=0):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
        x = InspectObjectOnScreenParam()
        x.Init(buf, n + offset)
        return x

    @classmethod
    def GetRootAsInspectObjectOnScreenParam(cls, buf, offset=0):
        """This method is deprecated. Please switch to GetRootAs."""
        return cls.GetRootAs(buf, offset)
    # InspectObjectOnScreenParam
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

    # InspectObjectOnScreenParam
    def Pos(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            x = o + self._tab.Pos
            from gamium.protocol.generated.Types.Vector2 import Vector2
            obj = Vector2()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # InspectObjectOnScreenParam
    def ScreenSize(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            x = o + self._tab.Pos
            from gamium.protocol.generated.Types.Vector2 import Vector2
            obj = Vector2()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

def InspectObjectOnScreenParamStart(builder): builder.StartObject(2)
def Start(builder):
    return InspectObjectOnScreenParamStart(builder)
def InspectObjectOnScreenParamAddPos(builder, pos): builder.PrependStructSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(pos), 0)
def AddPos(builder, pos):
    return InspectObjectOnScreenParamAddPos(builder, pos)
def InspectObjectOnScreenParamAddScreenSize(builder, screenSize): builder.PrependStructSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(screenSize), 0)
def AddScreenSize(builder, screenSize):
    return InspectObjectOnScreenParamAddScreenSize(builder, screenSize)
def InspectObjectOnScreenParamEnd(builder): return builder.EndObject()
def End(builder):
    return InspectObjectOnScreenParamEnd(builder)
import gamium.protocol.generated.Types.Vector2
try:
    from typing import Optional
except:
    pass

class InspectObjectOnScreenParamT(object):

    # InspectObjectOnScreenParamT
    def __init__(self):
        self.pos = None  # type: Optional[gamium.protocol.generated.Types.Vector2.Vector2T]
        self.screenSize = None  # type: Optional[gamium.protocol.generated.Types.Vector2.Vector2T]

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

    @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, inspectObjectOnScreenParam):
        x = InspectObjectOnScreenParamT()
        x._UnPack(inspectObjectOnScreenParam)
        return x

    # InspectObjectOnScreenParamT
    def _UnPack(self, inspectObjectOnScreenParam):
        if inspectObjectOnScreenParam is None:
            return
        if inspectObjectOnScreenParam.Pos() is not None:
            self.pos = gamium.protocol.generated.Types.Vector2.Vector2T.InitFromObj(inspectObjectOnScreenParam.Pos())
        if inspectObjectOnScreenParam.ScreenSize() is not None:
            self.screenSize = gamium.protocol.generated.Types.Vector2.Vector2T.InitFromObj(inspectObjectOnScreenParam.ScreenSize())

    # InspectObjectOnScreenParamT
    def Pack(self, builder):
        InspectObjectOnScreenParamStart(builder)
        if self.pos is not None:
            pos = self.pos.Pack(builder)
            InspectObjectOnScreenParamAddPos(builder, pos)
        if self.screenSize is not None:
            screenSize = self.screenSize.Pack(builder)
            InspectObjectOnScreenParamAddScreenSize(builder, screenSize)
        inspectObjectOnScreenParam = InspectObjectOnScreenParamEnd(builder)
        return inspectObjectOnScreenParam
