# automatically generated by the FlatBuffers compiler, do not modify

# namespace: Actions

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

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

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

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

    # MovePlayerParam
    def PlayerObjectId(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

    # MovePlayerParam
    def CameraObjectId(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

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

    # MovePlayerParam
    def By(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Int16Flags, o + self._tab.Pos)
        return 0

    # MovePlayerParam
    def Epsilon(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos)
        return 0.0

    # MovePlayerParam
    def CheckHeight(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
        return False

def MovePlayerParamStart(builder): builder.StartObject(6)
def Start(builder):
    return MovePlayerParamStart(builder)
def MovePlayerParamAddPlayerObjectId(builder, playerObjectId): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(playerObjectId), 0)
def AddPlayerObjectId(builder, playerObjectId):
    return MovePlayerParamAddPlayerObjectId(builder, playerObjectId)
def MovePlayerParamAddCameraObjectId(builder, cameraObjectId): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(cameraObjectId), 0)
def AddCameraObjectId(builder, cameraObjectId):
    return MovePlayerParamAddCameraObjectId(builder, cameraObjectId)
def MovePlayerParamAddPosition(builder, position): builder.PrependStructSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(position), 0)
def AddPosition(builder, position):
    return MovePlayerParamAddPosition(builder, position)
def MovePlayerParamAddBy(builder, by): builder.PrependInt16Slot(3, by, 0)
def AddBy(builder, by):
    return MovePlayerParamAddBy(builder, by)
def MovePlayerParamAddEpsilon(builder, epsilon): builder.PrependFloat32Slot(4, epsilon, 0.0)
def AddEpsilon(builder, epsilon):
    return MovePlayerParamAddEpsilon(builder, epsilon)
def MovePlayerParamAddCheckHeight(builder, checkHeight): builder.PrependBoolSlot(5, checkHeight, 0)
def AddCheckHeight(builder, checkHeight):
    return MovePlayerParamAddCheckHeight(builder, checkHeight)
def MovePlayerParamEnd(builder): return builder.EndObject()
def End(builder):
    return MovePlayerParamEnd(builder)
import gamium.protocol.generated.Types.Vector3
try:
    from typing import Optional
except:
    pass

class MovePlayerParamT(object):

    # MovePlayerParamT
    def __init__(self):
        self.playerObjectId = None  # type: str
        self.cameraObjectId = None  # type: str
        self.position = None  # type: Optional[gamium.protocol.generated.Types.Vector3.Vector3T]
        self.by = 0  # type: int
        self.epsilon = 0.0  # type: float
        self.checkHeight = False  # type: bool

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

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

    # MovePlayerParamT
    def _UnPack(self, movePlayerParam):
        if movePlayerParam is None:
            return
        self.playerObjectId = movePlayerParam.PlayerObjectId()
        self.cameraObjectId = movePlayerParam.CameraObjectId()
        if movePlayerParam.Position() is not None:
            self.position = gamium.protocol.generated.Types.Vector3.Vector3T.InitFromObj(movePlayerParam.Position())
        self.by = movePlayerParam.By()
        self.epsilon = movePlayerParam.Epsilon()
        self.checkHeight = movePlayerParam.CheckHeight()

    # MovePlayerParamT
    def Pack(self, builder):
        if self.playerObjectId is not None:
            playerObjectId = builder.CreateString(self.playerObjectId)
        if self.cameraObjectId is not None:
            cameraObjectId = builder.CreateString(self.cameraObjectId)
        MovePlayerParamStart(builder)
        if self.playerObjectId is not None:
            MovePlayerParamAddPlayerObjectId(builder, playerObjectId)
        if self.cameraObjectId is not None:
            MovePlayerParamAddCameraObjectId(builder, cameraObjectId)
        if self.position is not None:
            position = self.position.Pack(builder)
            MovePlayerParamAddPosition(builder, position)
        MovePlayerParamAddBy(builder, self.by)
        MovePlayerParamAddEpsilon(builder, self.epsilon)
        MovePlayerParamAddCheckHeight(builder, self.checkHeight)
        movePlayerParam = MovePlayerParamEnd(builder)
        return movePlayerParam
