Source code for babase._generated.base_asset_set

# Released under the MIT License. See LICENSE for details.
#
# AUTO-GENERATED by `tools/pcommand gen_base_asset_set_py`.
# DO NOT EDIT BY HAND.
#
# Generated from src/codegen/babasecodegen/base_assets.py.
"""Supplying base with the assets its classic-flavored art uses."""

from __future__ import annotations  # Docs-generation hack.

from typing import TYPE_CHECKING

import _babase

from babase import _builtinassets

if TYPE_CHECKING:
    from bacommon.assetspec import (
        CubeMapTextureSpec,
        MeshSpec,
        SoundSpec,
        TextureSpec,
    )


[docs] class BaseAssetSet: """Assets for the classic-flavored art baked into base. Base draws a few things whose *look* belongs to the classic game -- explosion debris, smoke, the VR boxing-glove hands, the reflection environment maps -- but whose draw code is engine-level. An app-mode carries one of these on its app-mode config and hands it to :func:`babase.set_base_asset_set` when activating to supply that art. Slots hold asset *references* (any wrapper flavor works); nothing loads until the set is applied. Every slot defaults to a neutral builtin placeholder (white texture, black cube map, box mesh), so a bare ``BaseAssetSet()`` is complete and renders a plain but coherent world: white debris, no reflections (a black cube map contributes nothing, since reflections are additive). """ # One attr per slot is the whole point of this class; the # complexity limits are aimed at hand-written code where # this shape signals trouble. # pylint: disable=too-many-instance-attributes # -- Environment cube maps for object reflections. The black # placeholder makes an unsupplied reflection a no-op (reflections are # additive). #: Reflection map for characters. reflection_char: CubeMapTextureSpec #: Reflection map for powerup boxes. reflection_powerup: CubeMapTextureSpec #: Soft reflection map. reflection_soft: CubeMapTextureSpec #: Sharp reflection map. reflection_sharp: CubeMapTextureSpec #: Sharper reflection map. reflection_sharper: CubeMapTextureSpec #: Sharpest reflection map. reflection_sharpest: CubeMapTextureSpec # -- Art for the engine-side effect systems -- bg_dynamics debris and # the smoke component. #: Smoke puff sheet. smoke: TextureSpec #: Spark streak. sparks: TextureSpec #: Bomb fuse. fuse: TextureSpec #: Rock shrapnel chunk color map. shrapnel_rock_color: TextureSpec #: Rock shrapnel chunk. shrapnel_rock: MeshSpec #: Wooden-board shrapnel chunk. shrapnel_board: MeshSpec #: Slime glob shrapnel chunk. shrapnel_slime: MeshSpec #: Light/shadow blotch (sharp). light: TextureSpec #: Light/shadow blotch (soft). light_soft: TextureSpec # -- Classic-look props base draws directly -- flag hardware and the # VR boxing-glove hands. #: Flag pole color map (bg_dynamics ropes). flag_pole_color: TextureSpec #: Flag base stand. flag_stand: MeshSpec #: Boxing glove (VR hands). boxing_glove: MeshSpec #: Boxing glove color map. boxing_gloves_color: TextureSpec #: Mask for character icons in kill messages. character_icon_mask: TextureSpec # -- Art for the on-screen touch controls -- the game-verb button # glyphs and movement arrows. #: Bomb/punch/jump/pickup button glyph sheet. action_buttons: TextureSpec #: Movement arrows sheet. touch_arrows: TextureSpec #: Movement arrows sheet (action variant). touch_arrows_actions: TextureSpec #: Single directional arrow. arrow: TextureSpec #: Bottom action-button backing. action_button_bottom: MeshSpec #: Left action-button backing. action_button_left: MeshSpec #: Right action-button backing. action_button_right: MeshSpec #: Top action-button backing. action_button_top: MeshSpec #: Back-arrow mesh. arrow_back: MeshSpec #: Front-arrow mesh. arrow_front: MeshSpec # -- Input-device connect/disconnect sounds. cork_pop defaults silent # (its art moved to classicassets); gun_cocking's wav is babase- # python-pinned so it stays builtin and defaults to the real thing. #: Device-connect jingle. cork_pop: SoundSpec #: Device-disconnect jingle. gun_cocking: SoundSpec def __init__(self) -> None: # All slots start at neutral builtin placeholders # (handles only; nothing is loaded here). self.reflection_char = _builtinassets.textures.black_cube self.reflection_powerup = _builtinassets.textures.black_cube self.reflection_soft = _builtinassets.textures.black_cube self.reflection_sharp = _builtinassets.textures.black_cube self.reflection_sharper = _builtinassets.textures.black_cube self.reflection_sharpest = _builtinassets.textures.black_cube self.smoke = _builtinassets.textures.white self.sparks = _builtinassets.textures.white self.fuse = _builtinassets.textures.white self.shrapnel_rock_color = _builtinassets.textures.white self.shrapnel_rock = _builtinassets.meshes.box self.shrapnel_board = _builtinassets.meshes.box self.shrapnel_slime = _builtinassets.meshes.box self.light = _builtinassets.textures.white self.light_soft = _builtinassets.textures.white self.flag_pole_color = _builtinassets.textures.white self.flag_stand = _builtinassets.meshes.box self.boxing_glove = _builtinassets.meshes.box self.boxing_gloves_color = _builtinassets.textures.white self.character_icon_mask = _builtinassets.textures.white self.action_buttons = _builtinassets.textures.white self.touch_arrows = _builtinassets.textures.white self.touch_arrows_actions = _builtinassets.textures.white self.arrow = _builtinassets.textures.white self.action_button_bottom = _builtinassets.meshes.box self.action_button_left = _builtinassets.meshes.box self.action_button_right = _builtinassets.meshes.box self.action_button_top = _builtinassets.meshes.box self.arrow_back = _builtinassets.meshes.box self.arrow_front = _builtinassets.meshes.box self.cork_pop = _builtinassets.audio.blank self.gun_cocking = _builtinassets.audio.gun_cocking
[docs] def set_base_asset_set(assets: BaseAssetSet) -> None: """Supply the art for base's classic-flavored draw paths. Called by an app-mode during activation (normally from :meth:`~babase.AppMode.on_activate`, with the :class:`BaseAssetSet` carried by its app-mode config). Loading happens native-side as the set is applied, so replaced placeholders are never loaded. At every app-mode switch the native set is *restored to placeholders* (not cleared -- base draws between modes too), so a mode can never inherit a previous mode's art. """ # Positional, in spec order -- the native side is generated # from the same spec, so the two cannot drift. _babase.set_base_asset_set_native( assets.reflection_char, assets.reflection_powerup, assets.reflection_soft, assets.reflection_sharp, assets.reflection_sharper, assets.reflection_sharpest, assets.smoke, assets.sparks, assets.fuse, assets.shrapnel_rock_color, assets.shrapnel_rock, assets.shrapnel_board, assets.shrapnel_slime, assets.light, assets.light_soft, assets.flag_pole_color, assets.flag_stand, assets.boxing_glove, assets.boxing_gloves_color, assets.character_icon_mask, assets.action_buttons, assets.touch_arrows, assets.touch_arrows_actions, assets.arrow, assets.action_button_bottom, assets.action_button_left, assets.action_button_right, assets.action_button_top, assets.arrow_back, assets.arrow_front, assets.cork_pop, assets.gun_cocking, )
# Docs-generation hack; import some stuff that we likely only forward-declared # in our actual source code so that docs tools can find it. from typing import (Coroutine, Any, Literal, Callable, Generator, Awaitable, Sequence, Self) import asyncio from concurrent.futures import Future from pathlib import Path from enum import Enum