# 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 ObjCharacterCore(PrettyPrint):
    def __init__(
            self,
            tick: int = 0,
            x: int = 0,
            y: int = 0,
            vel_x: int = 0,
            vel_y: int = 0,
            angle: int = 0,
            direction: int = 0,
            jumped: int = 0,
            hooked_player: int = 0,
            hook_state: int = 0,
            hook_tick: int = 0,
            hook_x: int = 0,
            hook_y: int = 0,
            hook_dx: int = 0,
            hook_dy: int = 0
    ) -> None:
        self.item_name: str = 'connless.character_core'
        self.type_id: int = 8
        self.id: int = 0
        self.size: int = 15

        self.tick: int = tick
        self.x: int = x
        self.y: int = y
        self.vel_x: int = vel_x
        self.vel_y: int = vel_y
        self.angle: int = angle
        self.direction: int = direction
        self.jumped: int = jumped
        self.hooked_player: int = hooked_player
        self.hook_state: int = hook_state
        self.hook_tick: int = hook_tick
        self.hook_x: int = hook_x
        self.hook_y: int = hook_y
        self.hook_dx: int = hook_dx
        self.hook_dy: int = hook_dy

    # 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:
        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()
        return True

    def pack(self) -> bytes:
        return pack_int(self.tick) + \
            pack_int(self.x) + \
            pack_int(self.y) + \
            pack_int(self.vel_x) + \
            pack_int(self.vel_y) + \
            pack_int(self.angle) + \
            pack_int(self.direction) + \
            pack_int(self.jumped) + \
            pack_int(self.hooked_player) + \
            pack_int(self.hook_state) + \
            pack_int(self.hook_tick) + \
            pack_int(self.hook_x) + \
            pack_int(self.hook_y) + \
            pack_int(self.hook_dx) + \
            pack_int(self.hook_dy)