# automatically generated by the FlatBuffers compiler, do not modify

# namespace: flat

import flatbuffers

# /// We have some very small messages that are only a few bytes but potentially sent at high frequency.
# /// Bundle them into a packet to reduce the overhead of sending data over TCP.
class MessagePacket(object):
    __slots__ = ['_tab']

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

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

    # MessagePacket
    def Messages(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            x = self._tab.Vector(o)
            x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
            x = self._tab.Indirect(x)
            from .GameMessageWrapper import GameMessageWrapper
            obj = GameMessageWrapper()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # MessagePacket
    def MessagesLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

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

    # MessagePacket
    def FrameNum(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
        return 0

def MessagePacketStart(builder): builder.StartObject(3)
def MessagePacketAddMessages(builder, messages): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(messages), 0)
def MessagePacketStartMessagesVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def MessagePacketAddGameSeconds(builder, gameSeconds): builder.PrependFloat32Slot(1, gameSeconds, 0.0)
def MessagePacketAddFrameNum(builder, frameNum): builder.PrependInt32Slot(2, frameNum, 0)
def MessagePacketEnd(builder): return builder.EndObject()
