mini_arcade_core.scenes.systems.builtins.actions ================================================ .. py:module:: mini_arcade_core.scenes.systems.builtins.actions .. autoapi-nested-parse:: Action-map based input bindings for scene systems. Attributes ---------- .. autoapisummary:: mini_arcade_core.scenes.systems.builtins.actions.TContext mini_arcade_core.scenes.systems.builtins.actions.TIntent Classes ------- .. autoapisummary:: mini_arcade_core.scenes.systems.builtins.actions.ActionState mini_arcade_core.scenes.systems.builtins.actions.ActionSnapshot mini_arcade_core.scenes.systems.builtins.actions.ActionBinding mini_arcade_core.scenes.systems.builtins.actions.DigitalActionBinding mini_arcade_core.scenes.systems.builtins.actions.AxisActionBinding mini_arcade_core.scenes.systems.builtins.actions.ActionMap mini_arcade_core.scenes.systems.builtins.actions.ActionIntentSystem Module Contents --------------- .. py:data:: TContext .. py:data:: TIntent .. py:class:: ActionState Normalized per-action state. .. py:attribute:: value :type: float :value: 0.0 .. py:attribute:: down :type: bool :value: False .. py:attribute:: pressed :type: bool :value: False .. py:attribute:: released :type: bool :value: False .. py:class:: ActionSnapshot Per-frame snapshot for all mapped actions. .. py:method:: state(action: str) -> ActionState Get the ActionState for the given action, or a default if not found. :param action: The name of the action to get the state for. :type action: str :return: The ActionState for the given action, or a default if not found. :rtype: ActionState .. py:method:: value(action: str, default: float = 0.0) -> float Get the normalized value of the action, or a default if not found. :param action: The name of the action to get the value for. :type action: str :param default: The default value to return if the action is not found (default 0.0). :type default: float :return: The normalized value of the action, or the default if not found. :rtype: float .. py:method:: down(action: str) -> bool Check if the action is currently held down. :param action: The name of the action to check. :type action: str :return: True if the action is currently held down, False otherwise. :rtype: bool .. py:method:: pressed(action: str) -> bool Check if the action was pressed this frame. :param action: The name of the action to check. :type action: str :return: True if the action was pressed this frame, False otherwise. :rtype: bool .. py:method:: released(action: str) -> bool Check if the action was released this frame. :param action: The name of the action to check. :type action: str :return: True if the action was released this frame, False otherwise. :rtype: bool .. py:class:: ActionBinding Bases: :py:obj:`Protocol` Strategy contract for one logical action binding. .. py:method:: read(frame: mini_arcade_core.runtime.input_frame.InputFrame) -> ActionState Read the current state of this action from the input frame. :param frame: The input frame containing raw input states. :type frame: InputFrame :return: The current ActionState for this binding. :rtype: ActionState .. py:class:: DigitalActionBinding Bases: :py:obj:`ActionBinding` Digital action sourced from keyboard and/or named buttons. .. py:attribute:: keys :type: tuple[mini_arcade_core.backend.keys.Key, Ellipsis] :value: () .. py:attribute:: buttons :type: tuple[str, Ellipsis] :value: () .. py:method:: read(frame: mini_arcade_core.runtime.input_frame.InputFrame) -> ActionState Read the current state of this action from the input frame. :param frame: The input frame containing raw input states. :type frame: InputFrame :return: The current ActionState for this binding. :rtype: ActionState .. py:class:: AxisActionBinding Bases: :py:obj:`ActionBinding` Axis action sourced from analog axes and optional digital fallbacks. .. py:attribute:: axes :type: tuple[str, Ellipsis] :value: () .. py:attribute:: positive_keys :type: tuple[mini_arcade_core.backend.keys.Key, Ellipsis] :value: () .. py:attribute:: negative_keys :type: tuple[mini_arcade_core.backend.keys.Key, Ellipsis] :value: () .. py:attribute:: positive_buttons :type: tuple[str, Ellipsis] :value: () .. py:attribute:: negative_buttons :type: tuple[str, Ellipsis] :value: () .. py:attribute:: deadzone :type: float :value: 0.15 .. py:attribute:: scale :type: float :value: 1.0 .. py:method:: read(frame: mini_arcade_core.runtime.input_frame.InputFrame) -> ActionState Read the current state of this action from the input frame. :param frame: The input frame containing raw input states. :type frame: InputFrame :return: The current ActionState for this binding. :rtype: ActionState .. py:class:: ActionMap Mapping of action IDs to concrete binding strategies. .. py:attribute:: bindings :type: Mapping[str, ActionBinding] .. py:method:: read(frame: mini_arcade_core.runtime.input_frame.InputFrame) -> ActionSnapshot Read the current state of all actions from the input frame. :param frame: The input frame containing raw input states. :type frame: InputFrame :return: An ActionSnapshot containing the state of all actions. :rtype: ActionSnapshot .. py:class:: ActionIntentSystem Bases: :py:obj:`mini_arcade_core.scenes.systems.base_system.BaseSystem`\ [\ :py:obj:`TContext`\ ], :py:obj:`Generic`\ [\ :py:obj:`TContext`\ , :py:obj:`TIntent`\ ] Input system that converts an ActionMap snapshot into scene intent. .. py:attribute:: action_map :type: ActionMap .. py:attribute:: intent_factory :type: Callable[[ActionSnapshot, TContext], TIntent] .. py:attribute:: name :type: str :value: 'action_intent' .. py:attribute:: order :type: int :value: 10 .. py:method:: step(ctx: TContext) -> None Perform a single step of the system within the given context. :param ctx: The system context. :type ctx: TSystemContext