# automatically generated by the FlatBuffers compiler, do not modify

# namespace: Actions

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

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

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

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

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

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

    # InputMouseParam
    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.Vector2 import Vector2
            obj = Vector2()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # InputMouseParam
    def Delta(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        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 InputMouseParamStart(builder): builder.StartObject(4)
def Start(builder):
    return InputMouseParamStart(builder)
def InputMouseParamAddPress(builder, press): builder.PrependInt16Slot(0, press, 0)
def AddPress(builder, press):
    return InputMouseParamAddPress(builder, press)
def InputMouseParamAddButton(builder, button): builder.PrependInt16Slot(1, button, 0)
def AddButton(builder, button):
    return InputMouseParamAddButton(builder, button)
def InputMouseParamAddPosition(builder, position): builder.PrependStructSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(position), 0)
def AddPosition(builder, position):
    return InputMouseParamAddPosition(builder, position)
def InputMouseParamAddDelta(builder, delta): builder.PrependStructSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(delta), 0)
def AddDelta(builder, delta):
    return InputMouseParamAddDelta(builder, delta)
def InputMouseParamEnd(builder): return builder.EndObject()
def End(builder):
    return InputMouseParamEnd(builder)
import gamium.protocol.generated.Types.Vector2
try:
    from typing import Optional
except:
    pass

class InputMouseParamT(object):

    # InputMouseParamT
    def __init__(self):
        self.press = 0  # type: int
        self.button = 0  # type: int
        self.position = None  # type: Optional[gamium.protocol.generated.Types.Vector2.Vector2T]
        self.delta = None  # type: Optional[gamium.protocol.generated.Types.Vector2.Vector2T]

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

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

    # InputMouseParamT
    def _UnPack(self, inputMouseParam):
        if inputMouseParam is None:
            return
        self.press = inputMouseParam.Press()
        self.button = inputMouseParam.Button()
        if inputMouseParam.Position() is not None:
            self.position = gamium.protocol.generated.Types.Vector2.Vector2T.InitFromObj(inputMouseParam.Position())
        if inputMouseParam.Delta() is not None:
            self.delta = gamium.protocol.generated.Types.Vector2.Vector2T.InitFromObj(inputMouseParam.Delta())

    # InputMouseParamT
    def Pack(self, builder):
        InputMouseParamStart(builder)
        InputMouseParamAddPress(builder, self.press)
        InputMouseParamAddButton(builder, self.button)
        if self.position is not None:
            position = self.position.Pack(builder)
            InputMouseParamAddPosition(builder, position)
        if self.delta is not None:
            delta = self.delta.Pack(builder)
            InputMouseParamAddDelta(builder, delta)
        inputMouseParam = InputMouseParamEnd(builder)
        return inputMouseParam
