mini_arcade_core.scenes.registry¶
SimScene registry for mini arcade core. Allows registering and creating scenes by string IDs.
Classes¶
Protocol for scene factory callables. |
|
Registry for scene factories, allowing registration and creation of scenes by string IDs. |
Module Contents¶
- class mini_arcade_core.scenes.registry.SceneFactory¶
Bases:
ProtocolProtocol for scene factory callables.
- class mini_arcade_core.scenes.registry.SceneRegistry¶
Registry for scene factories, allowing registration and creation of scenes by string IDs.
- property listed_scene_ids: list[str]¶
Get a list of all registered scene IDs.
- Returns:
A list of registered scene IDs.
- Return type:
list[str]
- register(scene_id: str, factory: SceneFactory)¶
Register a scene factory under a given scene ID.
- Parameters:
scene_id (str) – The string ID for the scene.
factory (SceneFactory) – A callable that creates a SimScene instance.
- register_cls(scene_id: str, scene_cls: type[mini_arcade_core.scenes.sim_scene.SimScene])¶
Register a SimScene class under a given scene ID.
- Parameters:
scene_id (str) – The string ID for the scene.
scene_cls (type["SimScene"]) – The SimScene class to register.
- create(scene_id: str, context: mini_arcade_core.runtime.context.RuntimeContext) mini_arcade_core.scenes.sim_scene.SimScene | None¶
Create a scene instance using the registered factory for the given scene ID.
- load_catalog(catalog: Dict[str, type[mini_arcade_core.scenes.sim_scene.SimScene]])¶
Load a catalog of SimScene classes into the registry.
- Parameters:
catalog (Dict[str, type["SimScene"]]) – A dictionary mapping scene IDs to SimScene classes.
- discover(*packages: str) SceneRegistry¶
Import all modules in a package so @scene decorators run.
- Parameters:
packages (str) – The package names to scan for scene modules.
- Returns:
The SceneRegistry instance (for chaining).
- Return type: