# 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.enum6 as enum6

class ObjCharacter(PrettyPrint):
    def __init__(
            self,
            player_flags: int = 0,
            health: int = 0,
            armor: int = 0,
            ammo_count: int = 0,
            weapon: int = enum6.Weapon.HAMMER.value,
            emote: int = enum6.Emote.NORMAL.value,
            attack_tick: int = 0
    ) -> None:
        self.item_name: str = 'connless.character'
        self.type_id: int = 9
        self.id: int = 0
        self.size: int = 22

        self.player_flags: int = player_flags
        self.health: int = health
        self.armor: int = armor
        self.ammo_count: int = ammo_count
        self.weapon: int = weapon
        self.emote: int = emote
        self.attack_tick: int = attack_tick

    # 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:
        # character_core
        self.tick = unpacker.get_int()
        self.x = unpacker.get_int()
        self.y = unpacker.get_int()
        self.vel_x = unpacker.get_int()
        self.vel_y = unpacker.get_int()
        self.angle = unpacker.get_int()
        self.direction = unpacker.get_int()
        self.jumped = unpacker.get_int()
        self.hooked_player = unpacker.get_int()
        self.hook_state = unpacker.get_int()
        self.hook_tick = unpacker.get_int()
        self.hook_x = unpacker.get_int()
        self.hook_y = unpacker.get_int()
        self.hook_dx = unpacker.get_int()
        self.hook_dy = unpacker.get_int()

        # character
        self.player_flags = unpacker.get_int()
        self.health = unpacker.get_int()
        self.armor = unpacker.get_int()
        self.ammo_count = unpacker.get_int()
        self.weapon = unpacker.get_int() # enum WEAPON
        self.emote = unpacker.get_int() # enum EMOTE
        self.attack_tick = unpacker.get_int()
        return True

    def pack(self) -> bytes:
        return pack_int(self.player_flags) + \
            pack_int(self.health) + \
            pack_int(self.armor) + \
            pack_int(self.ammo_count) + \
            pack_int(self.weapon) + \
            pack_int(self.emote) + \
            pack_int(self.attack_tick)