# automatically generated by the FlatBuffers compiler, do not modify

# namespace: flat

import flatbuffers

# /// A minimal version of the game tick packet, useful when bandwidth needs to be conserved.
class TinyPacket(object):
    __slots__ = ['_tab']

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

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

    # TinyPacket
    def Players(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 .TinyPlayer import TinyPlayer
            obj = TinyPlayer()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

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

    # TinyPacket
    def Ball(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            from .TinyBall import TinyBall
            obj = TinyBall()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

def TinyPacketStart(builder): builder.StartObject(2)
def TinyPacketAddPlayers(builder, players): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(players), 0)
def TinyPacketStartPlayersVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def TinyPacketAddBall(builder, ball): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(ball), 0)
def TinyPacketEnd(builder): return builder.EndObject()
