# generated by scripts/generate_messages.py

from typing import Any, Dict

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

class ObjDamageInd(PrettyPrint):
    def __init__(
            self,
            angle: int = 0
    ) -> None:
        self.item_name: str = 'item.damage_ind'
        self.type_id: int = 20
        self.id: int = 0
        self.size: int = 3

        self.angle: int = angle

    def __iter__(self):
        yield 'item_name', self.item_name
        yield 'type_id', self.type_id
        yield 'id', self.id
        yield 'size', self.size

        yield 'angle', self.angle

    def to_dict_payload_only(self) -> Dict[str, Any]:
        return {
            'angle': self.angle
        }

    # 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()

        # damage_ind
        self.angle = unpacker.get_int()
        return True

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