# automatically generated by the FlatBuffers compiler, do not modify

# namespace: Packets

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

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

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

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

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

def FindObjectsParamStart(builder): builder.StartObject(1)
def Start(builder):
    return FindObjectsParamStart(builder)
def FindObjectsParamAddLocator(builder, locator): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(locator), 0)
def AddLocator(builder, locator):
    return FindObjectsParamAddLocator(builder, locator)
def FindObjectsParamEnd(builder): return builder.EndObject()
def End(builder):
    return FindObjectsParamEnd(builder)
import gamium.protocol.generated.Types.ObjectLocator
try:
    from typing import Optional
except:
    pass

class FindObjectsParamT(object):

    # FindObjectsParamT
    def __init__(self):
        self.locator = None  # type: Optional[gamium.protocol.generated.Types.ObjectLocator.ObjectLocatorT]

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

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

    # FindObjectsParamT
    def _UnPack(self, findObjectsParam):
        if findObjectsParam is None:
            return
        if findObjectsParam.Locator() is not None:
            self.locator = gamium.protocol.generated.Types.ObjectLocator.ObjectLocatorT.InitFromObj(findObjectsParam.Locator())

    # FindObjectsParamT
    def Pack(self, builder):
        if self.locator is not None:
            locator = self.locator.Pack(builder)
        FindObjectsParamStart(builder)
        if self.locator is not None:
            FindObjectsParamAddLocator(builder, locator)
        findObjectsParam = FindObjectsParamEnd(builder)
        return findObjectsParam
