# 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 twnet_parser.packer import pack_int
from typing import Literal
import twnet_parser.enum7 as enum7

class MsgClSetSpectatorMode(PrettyPrint):
    def __init__(
            self,
            chunk_header: ChunkHeader = ChunkHeader(),
            spec_mode: int = enum7.Spec.FREEVIEW.value,
            spectator_id: int = 0
    ) -> None:
        self.message_type: Literal['system', 'game'] = 'game'
        self.message_name: str = 'cl_set_spectator_mode'
        self.system_message: bool = False
        self.message_id: int = 26
        self.header: ChunkHeader = chunk_header

        self.spec_mode: int = spec_mode
        self.spectator_id: int = spectator_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, data: bytes) -> bool:
        unpacker = Unpacker(data)
        self.spec_mode = unpacker.get_int() # enum SPEC
        self.spectator_id = unpacker.get_int()
        return True

    def pack(self) -> bytes:
        return pack_int(self.spec_mode) + \
            pack_int(self.spectator_id)