Esempio n. 1
0
void SoundSystem::TriggerEvent( char *_type, char *_eventName, Vector3<float> const &_pos )
{
    if( !m_channels ) return;

	START_PROFILE("TriggerEvent");
    
    SoundEventBlueprint *seb = m_blueprints.GetBlueprint(_type);
    if( seb )
    {
        for( int i = 0; i < seb->m_events.Size(); ++i )
        {
            SoundInstanceBlueprint *sib = seb->m_events[i];
            if( stricmp( sib->m_eventName, _eventName ) == 0 )
            {
                SoundInstance *instance = new SoundInstance();
                instance->Copy( sib->m_instance );
                instance->m_pos = _pos;
                bool success = InitialiseSound  ( instance );                
                if( !success ) ShutdownSound    ( instance );                
            }
        }
    }

	END_PROFILE("TriggerEvent");
}
Esempio n. 2
0
void SoundSystem::TriggerEvent( SoundObjectId _objId, char *_eventName )
{
    if( !m_channels ) return;

	START_PROFILE("TriggerEvent");
    
    char *objectType = m_interface->GetObjectType(_objId);
    if( objectType )
    {
        SoundEventBlueprint *seb = m_blueprints.GetBlueprint(objectType);
        if( seb )
        {
            for( int i = 0; i < seb->m_events.Size(); ++i )
            {
                SoundInstanceBlueprint *sib = seb->m_events[i];
                if( stricmp( sib->m_eventName, _eventName ) == 0 )
                {
                    Vector3<float> pos, vel;
                    m_interface->GetObjectPosition( _objId, pos, vel );

                    SoundInstance *instance = new SoundInstance();
                    instance->Copy( sib->m_instance );
                    instance->m_objIds.PutData( _objId );
                    instance->m_pos = pos;
                    instance->m_vel = vel;
                    bool success = InitialiseSound  ( instance );                
                    if( !success ) ShutdownSound    ( instance );                
                }
            }
        }
    }

	END_PROFILE("TriggerEvent");
}
Esempio n. 3
0
void SoundSystem::TriggerDuplicateSound ( SoundInstance *_instance )
{
    SoundInstance *newInstance = new SoundInstance();
    newInstance->Copy( _instance );
    newInstance->m_parent = _instance->m_parent;
    newInstance->m_pos = _instance->m_pos;
    newInstance->m_vel = _instance->m_vel;

    for( int i = 0; i < _instance->m_objIds.Size(); ++i )
    {
        SoundObjectId id = *_instance->m_objIds.GetPointer(i);
        newInstance->m_objIds.PutData( id );
    }

    bool success = InitialiseSound( newInstance );
    if( success && newInstance->m_positionType == SoundInstance::TypeInEditor )
    {
        m_editorInstanceId = newInstance->m_id;        
    }
    else if( !success )
    {
        ShutdownSound( newInstance);
    }
}