IEntityAudioComponent

IEntityAudioComponentabstract

#include

Inherits IEntityComponent.

Public Member Functions

virtual void SetFadeDistance (float const fadeDistance)=0
virtual float GetFadeDistance () const =0
virtual void SetEnvironmentFadeDistance (float const environmentFadeDistance)=0
virtual float GetEnvironmentFadeDistance () const =0
virtual float GetGreatestFadeDistance () const =0
virtual void SetEnvironmentId (CryAudio::EnvironmentId const environmentId)=0
virtual CryAudio::EnvironmentId GetEnvironmentId () const =0
virtual CryAudio::AuxObjectId CreateAudioAuxObject ()=0
virtual bool RemoveAudioAuxObject (CryAudio::AuxObjectId const audioAuxObjectId)=0
virtual void SetAudioAuxObjectOffset (Matrix34 const &offset, CryAudio::AuxObjectId const audioAuxObjectId=CryAudio::DefaultAuxObjectId)=0
virtual Matrix34 const & GetAudioAuxObjectOffset (CryAudio::AuxObjectId const audioAuxObjectId=CryAudio::DefaultAuxObjectId)=0
virtual bool PlayFile (CryAudio::SPlayFileInfo const &playbackInfo, CryAudio::AuxObjectId const audioAuxObjectId=CryAudio::DefaultAuxObjectId, CryAudio::SRequestUserData const &userData=CryAudio::SRequestUserData::GetEmptyObject())=0
virtual void StopFile (char const *const szFile, CryAudio::AuxObjectId const audioAuxObjectId=CryAudio::DefaultAuxObjectId)=0
virtual bool ExecuteTrigger (CryAudio::ControlId const audioTriggerId, CryAudio::AuxObjectId const audioAuxObjectId=CryAudio::DefaultAuxObjectId, CryAudio::SRequestUserData const &userData=CryAudio::SRequestUserData::GetEmptyObject())=0
virtual void StopTrigger (CryAudio::ControlId const audioTriggerId, CryAudio::AuxObjectId const audioAuxObjectId=CryAudio::DefaultAuxObjectId, CryAudio::SRequestUserData const &userData=CryAudio::SRequestUserData::GetEmptyObject())=0
virtual void SetSwitchState (CryAudio::ControlId const audioSwitchId, CryAudio::SwitchStateId const audioStateId, CryAudio::AuxObjectId const audioAuxObjectId=CryAudio::DefaultAuxObjectId)=0
virtual void SetParameter (CryAudio::ControlId const parameterId, float const value, CryAudio::AuxObjectId const audioAuxObjectId=CryAudio::DefaultAuxObjectId)=0
virtual void SetObstructionCalcType (CryAudio::EOcclusionType const occlusionType, CryAudio::AuxObjectId const audioAuxObjectId=CryAudio::DefaultAuxObjectId)=0
virtual void SetEnvironmentAmount (CryAudio::EnvironmentId const audioEnvironmentId, float const amount, CryAudio::AuxObjectId const audioAuxObjectId=CryAudio::DefaultAuxObjectId)=0
virtual void SetCurrentEnvironments (CryAudio::AuxObjectId const audioAuxObjectId=CryAudio::DefaultAuxObjectId)=0
virtual void AudioAuxObjectsMoveWithEntity (bool const bCanMoveWithEntity)=0
virtual void AddAsListenerToAudioAuxObject (CryAudio::AuxObjectId const audioAuxObjectId, void(*func)(CryAudio::SRequestInfo const *const), CryAudio::ESystemEvents const eventMask)=0
virtual void RemoveAsListenerFromAudioAuxObject (CryAudio::AuxObjectId const audioAuxObjectId, void(*func)(CryAudio::SRequestInfo const *const))=0
virtual CryAudio::AuxObjectId GetAuxObjectIdFromAudioObject (CryAudio::IObject *pObject)=0
- Public Member Functions inherited from IEntityComponent
virtual ICryFactory * GetFactory () const
ILINE IEntity * GetEntity () const
ILINE EntityId GetEntityId () const
IEntityComponent (IEntityComponent &&other)
IEntityComponent (const IEntityComponent &)=default
IEntityComponent & operator= (const IEntityComponent &)=default
IEntityComponent & operator= (IEntityComponent &&)=default
const CEntityComponentClassDesc & GetClassDesc () const
virtual uint64 GetEventMask () const
virtual ComponentEventPriority GetEventPriority () const
Determines the order in which this component will receive entity events (including update). Lower number indicates a higher priority.
virtual NetworkAspectType GetNetSerializeAspectMask () const
Network serialization. Override to provide a mask of active network aspects used by this component. Called once during binding to network. More...
virtual bool NetSerialize (TSerialize ser, EEntityAspects aspect, uint8 profile, int flags)
Network serialization. Will be called for each active aspect for both reading and writing. More...
virtual void NetReplicateSerialize (TSerialize ser)
virtual void NetMarkAspectsDirty (const NetworkAspectType aspects)
Call this to trigger aspect synchronization over the network. A shortcut. More...
virtual IEntityComponentPreviewer * GetPreviewer ()
Override this to return preview render interface for the component. Multiple component instances can usually share the same previewer class instance. More...
void SetComponentFlags (ComponentFlags flags)
END IEntityComponent virtual interface. More...
const ComponentFlags & GetComponentFlags () const
Return flags for this component.
ComponentFlags & GetComponentFlags ()
const CryGUID & GetGUID () const
IEntityComponent * GetParent () const
const CryTransform::CTransformPtr & GetTransform () const
Return Transformation of the entity component relative to the owning entity or parent component.
void SetTransformMatrix (const Matrix34 &transform)
Sets the transformation form a matrix. If the component doesn't have a transformation yet the function will add one.
void SetTransformMatrix (const CryTransform::CTransformPtr &transform)
Sets the transformation from another transformation. If the component doesn't have a transformation yet the function will add one.
Matrix34 GetWorldTransformMatrix () const
Return Transformation of the entity component relative to the world.
Matrix34 GetTransformMatrix () const
Return Calculated Transformation Matrix for current component transform.
const char * GetName () const
Get name of this individual component, usually only Schematyc components will have names.
void SetName (const char *szName)
int GetEntitySlotId () const
Return optional EntitySlot id used by this Component.
int GetOrMakeEntitySlotId ()
void SetEntitySlotId (int slotId)
Stores Entity slot id used by this component.
void FreeEntitySlot ()
Frees entity slot used by this component.
EEntitySimulationMode GetEntitySimulationMode () const
Return Current simulation mode of the host Entity.
void SendEvent (const SEntityEvent &event)
virtual void GetMemoryUsage (ICrySizer *pSizer) const
virtual void GameSerialize (TSerialize ser)
virtual bool NeedGameSerialize ()
virtual void LegacySerializeXML (XmlNodeRef &entityNode, XmlNodeRef &componentNode, bool bLoading)
virtual struct IEntityPropertyGroup * GetPropertyGroup ()
Only for backward compatibility to Release 5.3.0 for loading.
virtual EEntityProxy GetProxyType () const
Legacy, used for old entity proxies.

Additional Inherited Members

- Public Types inherited from IEntityComponent
typedef int ComponentEventPriority
typedef EEntityComponentFlags EFlags
typedef EntityComponentFlags ComponentFlags
- Static Public Attributes inherited from IEntityComponent
static constexpr int EmptySlotId = -1
- Protected Member Functions inherited from IEntityComponent
virtual void * QueryInterface (const CryInterfaceID &iid) const
virtual void * QueryComposite (const char *name) const
virtual void PreInit (const SInitParams &params)
virtual void Initialize ()
Called at the very first initialization of the component, at component creation time.
virtual void OnShutDown ()
Called on all Entity components right before all of the Entity Components are destructed.
virtual void OnTransformChanged ()
Called when the transformation of the component is changed.
virtual void ProcessEvent (const SEntityEvent &event)
- Protected Attributes inherited from IEntityComponent
friend IEntity
IEntity * m_pEntity = nullptr
ComponentFlags m_componentFlags
CryGUID m_guid
Unique GUID of the instance of this component.
string m_name
name of this component
CryTransform::CTransformPtr m_pTransform
Optional transformation setting for the component within the Entity object.
IEntityComponent * m_pParent = nullptr
Optional pointer to our parent component.
const CEntityComponentClassDesc * m_pClassDesc = nullptr
int m_entitySlotId = EmptySlotId
Optional Entity SlotId for storing component data like geometry of character.

Detailed Description

Helper component for playing back audio on the current world-space position of an entity. Wraps low-level CryAudio logic.

Member Function Documentation

◆ CreateAudioAuxObject()

virtual CryAudio::AuxObjectId IEntityAudioComponent::CreateAudioAuxObject ( )
pure virtual

Creates an additional audio object managed by this component, allowing individual handling of effects IEntityAudioComponent will always create an audio object by default where audio will be played unless otherwise specified.

◆ ExecuteTrigger()

virtual bool IEntityAudioComponent::ExecuteTrigger ( CryAudio::ControlId const audioTriggerId,
CryAudio::AuxObjectId const audioAuxObjectId = CryAudio::DefaultAuxObjectId,
CryAudio::SRequestUserData const & userData = CryAudio::SRequestUserData::GetEmptyObject()
)
pure virtual

Executes the specified trigger on the entity

Parameters
audioTriggerIdThe trigger we want to execute
audioAuxObjectIdAudio object within the component that we want to set, see IEntityAudioComponent::CreateAudioAuxObject. If not provided it is played on the default object.
#include 

// Simple example of how an audio trigger can be executed using IEntityAudioComponent 
void ExecuteTrigger(IEntity& entity)
{
    // Get the internal identifier for the trigger, computed at compile-time.
    // Note that the trigger itself is created by the Audio Controls Editor (ACE).
    constexpr CryAudio::ControlId triggerIdentifier = CryAudio::StringToId("MyTrigger");
    
    // Query whether an IEntityAudioComponent instance exists in the entity, if not create it.
    if (IEntityAudioComponent* pAudioComponent = entity.GetOrCreateComponent())
    {
        // Now execute the trigger on the entity, playing back anything contained within on the entities current transformation.
        pAudioComponent->ExecuteTrigger(triggerIdentifier);
    }
}

◆ SetParameter()

virtual void IEntityAudioComponent::SetParameter ( CryAudio::ControlId const parameterId,
float const value,
CryAudio::AuxObjectId const audioAuxObjectId = CryAudio::DefaultAuxObjectId
)
pure virtual

Sets the value of the specified parameter on the entity

Parameters
parameterIdIdentifier of the parameter we want to modify the value of
audioAuxObjectIdAudio object within the component that we want to set, see IEntityAudioComponent::CreateAudioAuxObject. If not provided it is played on the default object.
#include 

void SetParameterValue(IEntity& entity)
{
    // Get the internal identifier for the parameter, computed at compile-time.
    // Note that the parameter itself is created by the Audio Controls Editor (ACE).
    constexpr CryAudio::ControlId parameterIdentifier = CryAudio::StringToId("MyParameter");
    // The new value of the parameter that we want to set.
    const float newParameterValue = 5.0f;

    // Query whether an IEntityAudioComponent instance exists in the entity, if not create it.
    if (IEntityAudioComponent* pAudioComponent = entity.GetOrCreateComponent())
    {
        // Now set the new value of the parameter, affecting any triggers being executed now or in the future.
        pAudioComponent->SetParameter(parameterIdentifier, newParameterValue);
    }
}

◆ SetSwitchState()

virtual void IEntityAudioComponent::SetSwitchState ( CryAudio::ControlId const audioSwitchId,
CryAudio::SwitchStateId const audioStateId,
CryAudio::AuxObjectId const audioAuxObjectId = CryAudio::DefaultAuxObjectId
)
pure virtual

Sets the current state of a switch in the entity

Parameters
audioSwitchIdIdentifier of the switch whose state we want to change
audioStateIdIdentifier of the switch state we want to set to
audioAuxObjectIdAudio object within the component that we want to set, see IEntityAudioComponent::CreateAudioAuxObject. If not provided it is played on the default object.
#include 

void SetSwitchState(IEntity& entity)
{
    // Get the internal identifier for the switch, computed at compile-time.
    constexpr CryAudio::ControlId switchIdentifier = CryAudio::StringToId("MySwitch");
    // In addition, we need to get the identifier for any state we want to set on the switch as well.
    // Note that the switch and its states are created by the Audio Controls Editor (ACE) tool in the Editor. 
    constexpr CryAudio::SwitchStateId switchStateIdentifier = CryAudio::StringToId("MySwitchState");

    // Query whether an IEntityAudioComponent instance exists in the entity, if not create it.
    if (IEntityAudioComponent* pAudioComponent = entity.GetOrCreateComponent())
    {
        // Now set the new state of the switch, affecting any triggers being executed now or in the future.
        pAudioComponent->SetSwitchState(switchIdentifier, switchStateIdentifier);
    }
}