Monad Engine da02fba2
> Undercity Codex_
Loading...
Searching...
No Matches
mnd::AudioComponent Class Referenceabstract

Plays one or more named audio clips, attached to a GameObject. More...

#include <AudioComponent.h>

+ Inheritance diagram for mnd::AudioComponent:
+ Collaboration diagram for mnd::AudioComponent:

Public Member Functions

void LoadProperties (const nlohmann::json &json) override
 Read clips and properties from a serialised scene JSON entry.
 
void Update (float deltaTime) override
 Push the owner's world position to every registered clip.
 
void RegisterAudio (const std::string &name, std::shared_ptr< Audio > &clip)
 Add a clip under name; later calls reference it by that key.
 
void Play (const std::string &name, bool loop=false)
 Start the named clip; loop true loops forever.
 
void Stop (const std::string &name)
 Stop the named clip if it is currently playing.
 
bool IsPlaying (const std::string &name)
 True iff the named clip is currently playing.
 
virtual void Init ()
 
virtual size_t GetTypeId () const =0
 
GameObjectGetOwner ()
 

Static Public Member Functions

template<typename T >
static size_t StaticTypeId ()
 

Protected Attributes

GameObjectm_owner = nullptr
 

Detailed Description

Plays one or more named audio clips, attached to a GameObject.

Definition at line 29 of file AudioComponent.h.

Member Function Documentation

◆ GetOwner()

GameObject * mnd::Component::GetOwner ( )
inherited

◆ GetTypeId()

virtual size_t mnd::Component::GetTypeId ( ) const
pure virtualinherited

◆ Init()

void mnd::Component::Init ( )
virtualinherited

Reimplemented in mnd::PhysicsComponent, and mnd::PlayerControllerComponent.

Definition at line 10 of file Component.cpp.

Referenced by mnd::GameObject::AddComponent().

◆ IsPlaying()

bool mnd::AudioComponent::IsPlaying ( const std::string &  name)

True iff the named clip is currently playing.

Definition at line 68 of file AudioComponent.cpp.

◆ LoadProperties()

void mnd::AudioComponent::LoadProperties ( const nlohmann::json &  json)
overridevirtual

Read clips and properties from a serialised scene JSON entry.

Reimplemented from mnd::Component.

Definition at line 7 of file AudioComponent.cpp.

References mnd::Audio::Load(), and RegisterAudio().

◆ Play()

void mnd::AudioComponent::Play ( const std::string &  name,
bool  loop = false 
)

Start the named clip; loop true loops forever.

Definition at line 44 of file AudioComponent.cpp.

◆ RegisterAudio()

void mnd::AudioComponent::RegisterAudio ( const std::string &  name,
std::shared_ptr< Audio > &  clip 
)

Add a clip under name; later calls reference it by that key.

Definition at line 39 of file AudioComponent.cpp.

Referenced by LoadProperties().

◆ StaticTypeId()

template<typename T >
static size_t mnd::Component::StaticTypeId ( )
inlinestaticinherited

Definition at line 50 of file Component.h.

◆ Stop()

void mnd::AudioComponent::Stop ( const std::string &  name)

Stop the named clip if it is currently playing.

Definition at line 56 of file AudioComponent.cpp.

◆ Update()

void mnd::AudioComponent::Update ( float  deltaTime)
overridevirtual

Push the owner's world position to every registered clip.

Implements mnd::Component.

Definition at line 27 of file AudioComponent.cpp.

References mnd::GameObject::GetWorldPosition(), and mnd::Component::m_owner.

Member Data Documentation

◆ m_owner


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