asge::game::components::Sprite
A drawable texture reference, drawn each frame via RenderSystem.
#include <Sprite.hpp>Collaboration
classDiagram
class N1["asge::game::components::Sprite"]
class N3["asge::graphics::RGBA_Color"]
class N2["asge::video::ITexture"]
N1 --> N2 : m_Texture
N1 --> N3 : m_Tint
click N1 href "structasge_1_1game_1_1components_1_1Sprite.html"
click N3 href "structasge_1_1graphics_1_1RGBA__Color.html"
click N2 href "classasge_1_1video_1_1ITexture.html"
Non-owning: m_Texture must outlive every entity holding a Sprite that points to it — in practice asset::AssetManager, since a renderer (and so a texture) can't be created before one exists, so nothing can own the texture at component-construction time. asset::AssetManager:: ResolveAssets is what actually creates it and keeps it alive.
m_VirtualPath and m_SourceRect are what actually round-trip through TOML — m_Texture is a runtime-only pointer that can't be serialized, so ToToml/FromToml carry the path it was loaded from instead. FromToml leaves m_Texture null; asset::AssetManager::ResolveAssets is what resolves m_VirtualPath back into a live texture for every Sprite that still needs one. Draw order isn't a Sprite concern see components::RenderInfo for layer/y-sort/screen-space.
m_SourceRect is owned by components::Animation only while it is playing: AnimationSystem overwrites it every frame then, and restores the crop it found (a hand-set rect, or whole-texture nullopt) once the Animation stops or its clip is cleared. While nothing plays, the Sprite's own m_SourceRect is what is drawn.
Public Attributes
video::ITexture * m_Texture {nullptr}std::optional< math::Rect > m_SourceRect {}std::string m_VirtualPath {}graphics::RGBA_Color m_Tint {}std::string m_ResolvedVirtualPath {}