VFmodEvent* RPG_VisionEffectHelper::PlayFmodSoundEvent(VString const& eventGroupName, VString const& eventName, hkvVec3 const& position /*= hkvVec3(0.0f,0.0f,0.0f)*/, int flags/*=VFMOD_FLAG_NONE*/)
{
    VASSERT(!eventGroupName.IsEmpty());   // Name of the event group, relative to the event project
    VASSERT(!eventName.IsEmpty());        // name of the event, relative to the parent event-group

    VString const& eventProjectPath = RPG_GameManager::s_instance.GetFmodEventProject();
    VASSERT_MSG(!eventProjectPath.IsEmpty(), "Please ensure that GameManager::FMOD_EVENT_PROJECT points to a valid FMOD project file.");

#if (defined _DEBUG) && !(RPG_FMOD_SUPPRESS_NONNULL_ASSERTS)
    // @for testing only: validate the project filename
    FMOD::EventProject* pEventProject = VFmodManager::GlobalManager().LoadEventProject(eventProjectPath.AsChar());
    VASSERT_MSG(pEventProject, eventProjectPath.AsChar());
#endif

    // load event group
    VFmodEventGroup *pEventGroup = VFmodManager::GlobalManager().LoadEventGroup(eventProjectPath.AsChar(), eventGroupName.AsChar());
#if !(RPG_FMOD_SUPPRESS_NONNULL_ASSERTS)
    VASSERT_MSG(pEventGroup && pEventGroup->IsValid(), eventGroupName.AsChar());
#endif

    if (pEventGroup && pEventGroup->IsValid())
    {
        // create event instance
        VFmodEvent *pEvent = pEventGroup->CreateEvent(eventName.AsChar(), position, flags);
        VASSERT_MSG(pEvent && pEvent->IsValid(), eventName.AsChar());
        return pEvent;
    }
    return NULL;
}
Exemplo n.º 2
0
VFmodEvent* VFmodManager::CreateEvent(const char *szEventProjectPath, const char *szEventName, int iFlags)
{
  VASSERT(szEventProjectPath!=NULL && szEventName!=NULL); 
  char szEventGroupName[FS_MAX_PATH];
  VFileHelper::GetFileDir(szEventName, szEventGroupName);
  const char *szEventRelativeName = VFileHelper::GetFilename(szEventName);

  VFmodEventGroup *pEventGroup = LoadEventGroup(szEventProjectPath, szEventGroupName);
  if (!pEventGroup)
    return NULL;

  VFmodEvent* pEvent = pEventGroup->CreateEvent(szEventRelativeName, hkvVec3(0.0f,0.0f,0.0f), iFlags | VFMOD_FLAG_PAUSED);
  if (pEvent)
  {
    // Force event position update
    pEvent->OnObject3DChanged(VisObject3D_cl::VIS_OBJECT3D_POSCHANGED);

    // Play if set
    if((iFlags & VFMOD_FLAG_PAUSED) == 0)
      pEvent->Start();
  }

  return pEvent;
}