# generated by scripts/generate_messages.py

from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.chunk_header import ChunkHeader
from typing import Literal, Optional
from twnet_parser.snap6.projectile import ObjProjectile

class MsgSvExtraProjectile(PrettyPrint):
    def __init__(
            self,
            chunk_header: Optional[ChunkHeader] = None,
            projectile: Optional[ObjProjectile] = None
    ) -> None:
        self.message_type: Literal['system', 'game'] = 'game'
        self.message_name: str = 'sv_extra_projectile'
        self.system_message: bool = False
        self.message_id: int = 7
        if not chunk_header:
            chunk_header = ChunkHeader(version = '0.6')
        self.header: ChunkHeader = chunk_header

        if not projectile:
            projectile = ObjProjectile()
        self.projectile: ObjProjectile = projectile

    def __iter__(self):
        yield 'message_type', self.message_type
        yield 'message_name', self.message_name
        yield 'system_message', self.system_message
        yield 'message_id', self.message_id
        yield 'header', dict(self.header)

        yield 'projectile', self.projectile.to_dict_payload_only()

    # 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, data: bytes) -> bool:
        unpacker = Unpacker(data)
        self.projectile.unpack(unpacker)
        return True

    def pack(self) -> bytes:
        return self.projectile.pack()