Component responsible for attaching an asset to an entity. Can store meshes, textures, or any asset derived from Asset.
More...
#include <AssetComponent.hpp>
|
| | AssetComponent ()=default |
| | Default constructor.
|
| template<typename T> |
| std::shared_ptr< T > | GetAsset () const |
| | Returns the stored asset casted to the requested type.
|
| std::shared_ptr< Asset > | GetRawAsset () const |
| | Returns the raw asset pointer without casting.
|
| template<typename T> |
| void | LoadAsset (const std::string &path) |
| | Loads an asset from the AssetManager and stores it in this component.
|
| void | SetAsset (const std::shared_ptr< Asset > &asset) |
| | Manually assigns an already loaded asset to this component.
|
| void | Start () override |
| | Called when the component starts.
|
| void | Update (float dt) override |
| | Called every frame to update the component.
|
| void | OnDestroy () override |
| | Called when the component is destroyed. Releases the reference to the asset.
|
| virtual | ~Component ()=default |
| | Virtual destructor to allow proper cleanup of derived components.
|
| virtual std::string | GetTypeName () const =0 |
| | Returns the name of the component type. Useful for debugging, logging, or editor systems.
|
Component responsible for attaching an asset to an entity. Can store meshes, textures, or any asset derived from Asset.
◆ AssetComponent()
| Engine::AssetComponent::AssetComponent |
( |
| ) |
|
|
default |
◆ GetAsset()
template<typename T>
| std::shared_ptr< T > Engine::AssetComponent::GetAsset |
( |
| ) |
const |
|
inline |
Returns the stored asset casted to the requested type.
- Template Parameters
-
- Returns
- Shared pointer to the asset if the cast succeeds
◆ GetRawAsset()
| std::shared_ptr< Asset > Engine::AssetComponent::GetRawAsset |
( |
| ) |
const |
|
inline |
Returns the raw asset pointer without casting.
- Returns
- Shared pointer to the base Asset
◆ LoadAsset()
template<typename T>
| void Engine::AssetComponent::LoadAsset |
( |
const std::string & | path | ) |
|
|
inline |
Loads an asset from the AssetManager and stores it in this component.
- Template Parameters
-
- Parameters
-
| path | Path to the asset file |
◆ OnDestroy()
| void Engine::AssetComponent::OnDestroy |
( |
| ) |
|
|
inlineoverridevirtual |
Called when the component is destroyed. Releases the reference to the asset.
Reimplemented from Engine::Component.
◆ SetAsset()
| void Engine::AssetComponent::SetAsset |
( |
const std::shared_ptr< Asset > & | asset | ) |
|
|
inline |
Manually assigns an already loaded asset to this component.
- Parameters
-
| asset | Shared pointer to the asset |
◆ Start()
| void Engine::AssetComponent::Start |
( |
| ) |
|
|
inlineoverridevirtual |
◆ Update()
| void Engine::AssetComponent::Update |
( |
float | dt | ) |
|
|
inlineoverridevirtual |
Called every frame to update the component.
- Parameters
-
| dt | Delta time between frames |
Reimplemented from Engine::Component.
The documentation for this class was generated from the following file: