private static bool PlayEvent(string eventName, Func <Vector3> getPosFunc, int?stateInfo) { //if (!(GameDataManager.GameType == GameDataManager.GameTypes.DS1 || // GameDataManager.GameType == GameDataManager.GameTypes.DS1R || // GameDataManager.GameType == GameDataManager.GameTypes.DS3 || // GameDataManager.GameType == GameDataManager.GameTypes.SDT)) //{ // return false; //} bool result = false; Main.WinForm.Invoke(new Action(() => { FMOD.EventProject evProject = null; bool foundEvent = false; FMOD.Event newEvent = null; string newEvent_FullFevPath = null; foreach (var fevName in LoadedFEVs) { var fres = _eventSystem.getProject(fevName, ref evProject); if (fres == RESULT.OK) { int groupCount = 0; fres = evProject.getNumGroups(ref groupCount); if (fres == RESULT.OK) { bool searchGroup(FMOD.EventGroup grp) { fres = grp.getEvent(eventName, EVENT_MODE.DEFAULT, ref newEvent); if (fres == RESULT.OK) { newEvent_FullFevPath = _loadedFEVs_FullPaths[fevName]; return(true); // Returning from searchGroup() lol } int numInnerGroups = 0; fres = grp.getNumGroups(ref numInnerGroups); if (fres == RESULT.OK) { for (int j = 0; j < numInnerGroups; j++) { FMOD.EventGroup innerInnerGroup = null; fres = grp.getGroupByIndex(j, false, ref innerInnerGroup); if (fres == RESULT.OK) { if (searchGroup(innerInnerGroup)) { newEvent_FullFevPath = _loadedFEVs_FullPaths[fevName]; return(true); } } } } return(false); } for (int i = 0; i < groupCount; i++) { FMOD.EventGroup innerGroup = null; fres = evProject.getGroupByIndex(i, cacheevents: false, ref innerGroup); if (fres == RESULT.OK) { if (searchGroup(innerGroup)) { foundEvent = true; break; } } } } } } if (!foundEvent) { result = false; return; } lock (_lock_MediaRoot) { UpdateMediaRoot(Path.GetDirectoryName(newEvent_FullFevPath)); ERRCHECK(newEvent.setVolume(BaseSoundVolume * (AdjustSoundVolume / 100))); if (getPosFunc != null) { lock (_lock_eventsToUpdate) { _eventsToUpdate.Add(new FmodEventUpdater(newEvent, getPosFunc, eventName, stateInfo)); } } ERRCHECK(newEvent.start()); result = true; } })); return(result); }
private static bool PlayEvent(string eventName, Func <Vector3> getPosFunc = null) { if (!(GameDataManager.GameType == GameDataManager.GameTypes.DS1 || GameDataManager.GameType == GameDataManager.GameTypes.DS1R || GameDataManager.GameType == GameDataManager.GameTypes.DS3 || GameDataManager.GameType == GameDataManager.GameTypes.SDT)) { return(false); } bool result = false; Main.WinForm.Invoke(new Action(() => { FMOD.EventProject evProject = null; bool foundEvent = false; FMOD.Event newEvent = null; foreach (var fevName in LoadedFEVs) { var fres = _eventSystem.getProject(fevName, ref evProject); if (fres == RESULT.OK) { int groupCount = 0; fres = evProject.getNumGroups(ref groupCount); if (fres == RESULT.OK) { for (int i = 0; i < groupCount; i++) { FMOD.EventGroup innerGroup = null; fres = evProject.getGroupByIndex(i, cacheevents: false, ref innerGroup); if (fres == RESULT.OK) { fres = innerGroup.getEvent(eventName, EVENT_MODE.DEFAULT, ref newEvent); if (fres == RESULT.OK) { foundEvent = true; break; } } } } } } if (!foundEvent) { result = false; return; } ERRCHECK(newEvent.setVolume(BaseSoundVolume * AdjustSoundVolume)); if (getPosFunc != null) { lock (_lock_eventsToUpdate) { _eventsToUpdate.Add(new FmodEventUpdater(newEvent, getPosFunc, eventName)); } } ERRCHECK(newEvent.start()); result = true; })); return(result); }
// PLAY THE SOUND OF THE CURRENT EVENT public void start(ref FMOD.Event evt) { evt.start(); }