def __init__(self, key, command, flags=0, other_command=None, animation_to_complete=None):
"""
:param str key: the key's description, e.g. `up` for K_UP
:param str command: the `main` command's description; can be any string e.g. `fire`, `jump`
:param int flags: keyboard-command behavior flags
:param str other_command: a possible second command associated with the key (when key is released, e.g. `release_bow`)
:param Union[list,str] animation_to_complete: animation(s) that needs to be completed in order for the other_command to be executable
"""
self.key = key
self.command = command
assert flags & (self.BLOCK_REPEAT_UNTIL_ANIM_COMPLETE | self.BLOCK_OTHER_CMD_UNTIL_ANIM_COMPLETE) == 0 or \
isinstance(animation_to_complete, str) or isinstance(animation_to_complete, set), "ERROR: animation_to_complete needs to be of type str or set!"
self.flags = flags
self.other_command = other_command
# this could be a set of anims (one of them has to be completed)
self.animation_to_complete = {animation_to_complete} if isinstance(animation_to_complete, str) else animation_to_complete
self.state_other_command = 0 # the current state for the other_command (charging, charged, cmd_received)
self.is_disabled = False # set to True for temporarily blocking this translation
评论列表
文章目录