# automatically generated by the FlatBuffers compiler, do not modify

# namespace: fbs

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

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

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

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

    # Observation
    def Glyphs(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            from nle.fbs.NDArray import NDArray
            obj = NDArray()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Observation
    def Chars(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            from nle.fbs.NDArray import NDArray
            obj = NDArray()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Observation
    def Colors(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            from nle.fbs.NDArray import NDArray
            obj = NDArray()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Observation
    def Specials(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            from nle.fbs.NDArray import NDArray
            obj = NDArray()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Observation
    def Status(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            from nle.fbs.Status import Status
            obj = Status()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Observation
    def Inventory(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            x = self._tab.Vector(o)
            x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
            x = self._tab.Indirect(x)
            from nle.fbs.InventoryItem import InventoryItem
            obj = InventoryItem()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # Observation
    def InventoryLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # Observation
    def InventoryIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        return o == 0

def ObservationStart(builder): builder.StartObject(6)
def ObservationAddGlyphs(builder, glyphs): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(glyphs), 0)
def ObservationAddChars(builder, chars): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(chars), 0)
def ObservationAddColors(builder, colors): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(colors), 0)
def ObservationAddSpecials(builder, specials): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(specials), 0)
def ObservationAddStatus(builder, status): builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(status), 0)
def ObservationAddInventory(builder, inventory): builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(inventory), 0)
def ObservationStartInventoryVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def ObservationEnd(builder): return builder.EndObject()
