My Project
Loading...
Searching...
No Matches
Engine::AssetComponent Class Reference

Component responsible for attaching an asset to an entity. Can store meshes, textures, or any asset derived from Asset. More...

#include <AssetComponent.hpp>

Inheritance diagram for Engine::AssetComponent:
Engine::Component

Public Member Functions

 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< AssetGetRawAsset () 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.
Public Member Functions inherited from Engine::Component
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.

Additional Inherited Members

Public Attributes inherited from Engine::Component
GameObjectgameObject = nullptr
 Pointer to the GameObject that owns this component.
Protected Member Functions inherited from Engine::Component
 Component ()=default
 Protected constructor to prevent direct instantiation of the base class.

Detailed Description

Component responsible for attaching an asset to an entity. Can store meshes, textures, or any asset derived from Asset.

Constructor & Destructor Documentation

◆ AssetComponent()

Engine::AssetComponent::AssetComponent ( )
default

Default constructor.

Member Function Documentation

◆ GetAsset()

template<typename T>
std::shared_ptr< T > Engine::AssetComponent::GetAsset ( ) const
inline

Returns the stored asset casted to the requested type.

Template Parameters
TRequested asset type
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
TType of asset to load
Parameters
pathPath 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
assetShared pointer to the asset

◆ Start()

void Engine::AssetComponent::Start ( )
inlineoverridevirtual

Called when the component starts.

Reimplemented from Engine::Component.

◆ Update()

void Engine::AssetComponent::Update ( float dt)
inlineoverridevirtual

Called every frame to update the component.

Parameters
dtDelta time between frames

Reimplemented from Engine::Component.


The documentation for this class was generated from the following file: