# 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

class ObjDeath(PrettyPrint):
    def __init__(
            self,
            client_id: int = 0
    ) -> None:
        self.item_name: str = 'connless.death'
        self.type_id: int = 17
        self.id: int = 0
        self.size: int = 3

        self.client_id: int = client_id

    # 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:
        # common
        self.x = unpacker.get_int()
        self.y = unpacker.get_int()

        # death
        self.client_id = unpacker.get_int()
        return True

    def pack(self) -> bytes:
        return pack_int(self.client_id)