mini_arcade_core.engine.commands ================================ .. py:module:: mini_arcade_core.engine.commands .. autoapi-nested-parse:: Command protocol for executing commands with a given context. Attributes ---------- .. autoapisummary:: mini_arcade_core.engine.commands.TContext Classes ------- .. autoapisummary:: mini_arcade_core.engine.commands.CommandContext mini_arcade_core.engine.commands.Command mini_arcade_core.engine.commands.CommandQueue mini_arcade_core.engine.commands.QuitCommand mini_arcade_core.engine.commands.ScreenshotCommand mini_arcade_core.engine.commands.PushSceneCommand mini_arcade_core.engine.commands.PopSceneCommand mini_arcade_core.engine.commands.ChangeSceneCommand mini_arcade_core.engine.commands.PushSceneIfMissingCommand mini_arcade_core.engine.commands.RemoveSceneCommand mini_arcade_core.engine.commands.ToggleDebugOverlayCommand mini_arcade_core.engine.commands.ToggleEffectCommand mini_arcade_core.engine.commands.StartReplayRecordCommand mini_arcade_core.engine.commands.StopReplayRecordCommand mini_arcade_core.engine.commands.StartReplayPlayCommand mini_arcade_core.engine.commands.StopReplayPlayCommand mini_arcade_core.engine.commands.StartVideoRecordCommand mini_arcade_core.engine.commands.StopVideoRecordCommand mini_arcade_core.engine.commands.ToggleVideoRecordCommand Module Contents --------------- .. py:data:: TContext .. py:class:: CommandContext Context for command execution. :ivar services (RuntimeServices): The runtime services. :ivar commands (CommandQueue | None): Optional command queue. :ivar settings (object | None): Optional settings object. :ivar world (object | None): The world object (can be any type). .. py:attribute:: services :type: mini_arcade_core.runtime.services.RuntimeServices .. py:attribute:: managers :type: object .. py:attribute:: settings :type: Optional[object] :value: None .. py:attribute:: world :type: Optional[object] :value: None .. py:class:: Command Bases: :py:obj:`Protocol` A command is the only allowed "write path" from input/systems into: - scene operations (push/pop/change/quit) - capture - global game lifecycle - later: world mutations (if you pass a world reference) For now we keep it simple: commands only need RuntimeServices. .. py:method:: execute(context: CommandContext) Execute the command with the given world and runtime services. :param services: Runtime services for command execution. :type services: RuntimeServices :param commands: Optional command queue for command execution. :type commands: object | None :param settings: Optional settings object for command execution. :type settings: object | None :param world: The world object (can be any type). :type world: object | None .. py:class:: CommandQueue Queue for storing and executing commands. .. py:method:: push(cmd: Command) Push a command onto the queue. :param cmd: Command to be added to the queue. :type cmd: Command .. py:method:: drain() -> List[Command] Drain and return all commands from the queue. :return: List of commands that were in the queue. :rtype: list[Command] .. py:class:: QuitCommand Bases: :py:obj:`Command` Quit the game. .. py:method:: execute(context: CommandContext) Execute the command with the given world and runtime services. :param services: Runtime services for command execution. :type services: RuntimeServices :param commands: Optional command queue for command execution. :type commands: object | None :param settings: Optional settings object for command execution. :type settings: object | None :param world: The world object (can be any type). :type world: object | None .. py:class:: ScreenshotCommand Bases: :py:obj:`Command` Take a screenshot. :ivar label (str | None): Optional label for the screenshot file. .. py:attribute:: label :type: str | None :value: None .. py:method:: execute(context: CommandContext) Execute the command with the given world and runtime services. :param services: Runtime services for command execution. :type services: RuntimeServices :param commands: Optional command queue for command execution. :type commands: object | None :param settings: Optional settings object for command execution. :type settings: object | None :param world: The world object (can be any type). :type world: object | None .. py:class:: PushSceneCommand Bases: :py:obj:`Command` Push a new scene onto the scene stack. :ivar scene_id (str): Identifier of the scene to push. :ivar as_overlay (bool): Whether to push the scene as an overlay. .. py:attribute:: scene_id :type: str .. py:attribute:: as_overlay :type: bool :value: False .. py:method:: execute(context: CommandContext) Execute the command with the given world and runtime services. :param services: Runtime services for command execution. :type services: RuntimeServices :param commands: Optional command queue for command execution. :type commands: object | None :param settings: Optional settings object for command execution. :type settings: object | None :param world: The world object (can be any type). :type world: object | None .. py:class:: PopSceneCommand Bases: :py:obj:`Command` Pop the current scene from the scene stack. .. py:method:: execute(context: CommandContext) Execute the command with the given world and runtime services. :param services: Runtime services for command execution. :type services: RuntimeServices :param commands: Optional command queue for command execution. :type commands: object | None :param settings: Optional settings object for command execution. :type settings: object | None :param world: The world object (can be any type). :type world: object | None .. py:class:: ChangeSceneCommand Bases: :py:obj:`Command` Change the current scene to the specified scene. :ivar scene_id (str): Identifier of the scene to switch to. .. py:attribute:: scene_id :type: str .. py:method:: execute(context: CommandContext) Execute the command with the given world and runtime services. :param services: Runtime services for command execution. :type services: RuntimeServices :param commands: Optional command queue for command execution. :type commands: object | None :param settings: Optional settings object for command execution. :type settings: object | None :param world: The world object (can be any type). :type world: object | None .. py:class:: PushSceneIfMissingCommand Bases: :py:obj:`Command` Push a scene only if it is not already in the stack. .. py:attribute:: scene_id :type: str .. py:attribute:: as_overlay :type: bool :value: False .. py:attribute:: policy :type: mini_arcade_core.engine.scenes.models.ScenePolicy | None :value: None .. py:method:: execute(context: CommandContext) Execute the command with the given world and runtime services. :param services: Runtime services for command execution. :type services: RuntimeServices :param commands: Optional command queue for command execution. :type commands: object | None :param settings: Optional settings object for command execution. :type settings: object | None :param world: The world object (can be any type). :type world: object | None .. py:class:: RemoveSceneCommand Bases: :py:obj:`Command` Remove a specific scene instance from the scene stack. .. py:attribute:: scene_id :type: str .. py:method:: execute(context: CommandContext) Execute the command with the given world and runtime services. :param services: Runtime services for command execution. :type services: RuntimeServices :param commands: Optional command queue for command execution. :type commands: object | None :param settings: Optional settings object for command execution. :type settings: object | None :param world: The world object (can be any type). :type world: object | None .. py:class:: ToggleDebugOverlayCommand Bases: :py:obj:`Command` Toggle the debug overlay scene. :cvar DEBUG_OVERLAY_ID: str: Identifier for the debug overlay scene. .. py:attribute:: DEBUG_OVERLAY_ID :value: 'debug_overlay' .. py:method:: execute(context: CommandContext) Execute the command with the given world and runtime services. :param services: Runtime services for command execution. :type services: RuntimeServices :param commands: Optional command queue for command execution. :type commands: object | None :param settings: Optional settings object for command execution. :type settings: object | None :param world: The world object (can be any type). :type world: object | None .. py:class:: ToggleEffectCommand Bases: :py:obj:`Command` Toggle a post-processing effect on or off. :ivar effect_id (str): Identifier of the effect to toggle. .. py:attribute:: effect_id :type: str .. py:method:: execute(context: CommandContext) Execute the command with the given world and runtime services. :param services: Runtime services for command execution. :type services: RuntimeServices :param commands: Optional command queue for command execution. :type commands: object | None :param settings: Optional settings object for command execution. :type settings: object | None :param world: The world object (can be any type). :type world: object | None .. py:class:: StartReplayRecordCommand Bases: :py:obj:`Command` Start recording a replay to the specified file. :ivar filename (str): The filename to save the replay to. :ivar game_id (str): Identifier of the game. :ivar initial_scene (str): The initial scene of the replay. :ivar seed (int): The random seed used in the replay. :ivar fps (int): Frames per second for the replay. .. py:attribute:: filename :type: str .. py:attribute:: game_id :type: str :value: 'mini-arcade' .. py:attribute:: initial_scene :type: str :value: 'unknown' .. py:attribute:: seed :type: int :value: 0 .. py:attribute:: fps :type: int :value: 60 .. py:method:: execute(context: CommandContext) Execute the command with the given world and runtime services. :param services: Runtime services for command execution. :type services: RuntimeServices :param commands: Optional command queue for command execution. :type commands: object | None :param settings: Optional settings object for command execution. :type settings: object | None :param world: The world object (can be any type). :type world: object | None .. py:class:: StopReplayRecordCommand Bases: :py:obj:`Command` Stop recording the current replay. .. py:method:: execute(context: CommandContext) Execute the command with the given world and runtime services. :param services: Runtime services for command execution. :type services: RuntimeServices :param commands: Optional command queue for command execution. :type commands: object | None :param settings: Optional settings object for command execution. :type settings: object | None :param world: The world object (can be any type). :type world: object | None .. py:class:: StartReplayPlayCommand Bases: :py:obj:`Command` Start playing back a replay from the specified file. :ivar path (str): The path to the replay file. :ivar change_scene (bool): Whether to change to the replay's initial scene. .. py:attribute:: path :type: str .. py:attribute:: change_scene :type: bool :value: True .. py:method:: execute(context: CommandContext) Execute the command with the given world and runtime services. :param services: Runtime services for command execution. :type services: RuntimeServices :param commands: Optional command queue for command execution. :type commands: object | None :param settings: Optional settings object for command execution. :type settings: object | None :param world: The world object (can be any type). :type world: object | None .. py:class:: StopReplayPlayCommand Bases: :py:obj:`Command` Stop playing back the current replay. .. py:method:: execute(context: CommandContext) Execute the command with the given world and runtime services. :param services: Runtime services for command execution. :type services: RuntimeServices :param commands: Optional command queue for command execution. :type commands: object | None :param settings: Optional settings object for command execution. :type settings: object | None :param world: The world object (can be any type). :type world: object | None .. py:class:: StartVideoRecordCommand Bases: :py:obj:`Command` Start recording a video. :ivar fps (int): Frames per second for the video. :ivar capture_fps (int): Frames per second for capturing frames. .. py:attribute:: fps :type: int :value: 60 .. py:attribute:: capture_fps :type: int :value: 30 .. py:method:: execute(context: CommandContext) Execute the command with the given world and runtime services. :param services: Runtime services for command execution. :type services: RuntimeServices :param commands: Optional command queue for command execution. :type commands: object | None :param settings: Optional settings object for command execution. :type settings: object | None :param world: The world object (can be any type). :type world: object | None .. py:class:: StopVideoRecordCommand Bases: :py:obj:`Command` Stop recording the current video. .. py:method:: execute(context: CommandContext) Execute the command with the given world and runtime services. :param services: Runtime services for command execution. :type services: RuntimeServices :param commands: Optional command queue for command execution. :type commands: object | None :param settings: Optional settings object for command execution. :type settings: object | None :param world: The world object (can be any type). :type world: object | None .. py:class:: ToggleVideoRecordCommand Bases: :py:obj:`Command` Toggle video recording on or off. :ivar fps (int): Frames per second for the video. :ivar capture_fps (int): Frames per second for capturing frames. .. py:attribute:: fps :type: int :value: 60 .. py:attribute:: capture_fps :type: int :value: 30 .. py:method:: execute(context: CommandContext) Execute the command with the given world and runtime services. :param services: Runtime services for command execution. :type services: RuntimeServices :param commands: Optional command queue for command execution. :type commands: object | None :param settings: Optional settings object for command execution. :type settings: object | None :param world: The world object (can be any type). :type world: object | None