# generated by scripts/generate_messages.py

from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.packer import pack_int
import twnet_parser.enum7 as enum7

class ObjPickup(PrettyPrint):
    def __init__(
            self,
            x: int = 0,
            y: int = 0,
            type: int = enum7.Pickup.HEALTH.value
    ) -> None:
        self.item_name: str = 'connless.pickup'
        self.type_id: int = 4
        self.id: int = 0
        self.size: int = 3

        self.x: int = x
        self.y: int = y
        self.type: int = type

    # first byte of data
    # has to be the first byte of the message payload
    # NOT the chunk header and NOT the message id
    def unpack(self, unpacker: Unpacker) -> bool:
        self.x = unpacker.get_int()
        self.y = unpacker.get_int()
        self.type = unpacker.get_int() # enum PICKUP
        return True

    def pack(self) -> bytes:
        return pack_int(self.x) + \
            pack_int(self.y) + \
            pack_int(self.type)