Ejemplo n.º 1
0
        public static FMOD.EventProject GetEventProject(string name)
        {
            FMOD.EventProject proj = null;
            var numProjects        = 0;

            result          = _eventSystem.getNumProjects(ref numProjects);
            ERRCHECK(result = _eventSystem.getProjectByIndex(0, ref proj));
            return(proj);
        }
Ejemplo n.º 2
0
        // FEV load/unload.
        public RESULT load(string name_or_data, ref EVENT_LOADINFO loadinfo, ref EventProject project)
        {
            RESULT result                  = RESULT.OK;
            IntPtr eventprojectraw         = new IntPtr();
            EventProject eventprojectnew   = null;

            try
            {
                result = FMOD_EventSystem_Load(eventsystemraw, name_or_data, ref loadinfo, ref eventprojectraw);
            }
            catch
            {
                result = RESULT.ERR_INVALID_PARAM;
            }
            if (result != RESULT.OK)
            {
                return result;
            }

            if (project == null)
            {
                eventprojectnew = new EventProject();
                eventprojectnew.setRaw(eventprojectraw);
                project = eventprojectnew;
            }
            else
            {
                project.setRaw(eventprojectraw);
            }

            return result;
        }
Ejemplo n.º 3
0
        public RESULT getProjectByIndex(int index, ref EventProject project)
        {
            RESULT result                  = RESULT.OK;
            IntPtr eventprojectraw         = new IntPtr();
            EventProject eventprojectnew   = null;

            try
            {
                result = FMOD_EventSystem_GetProjectByIndex(eventsystemraw, index, ref eventprojectraw);
            }
            catch
            {
                result = RESULT.ERR_INVALID_PARAM;
            }
            if (result != RESULT.OK)
            {
                return result;
            }

            if (project == null)
            {
                eventprojectnew = new EventProject();
                eventprojectnew.setRaw(eventprojectraw);
                project = eventprojectnew;
            }
            else
            {
                project.setRaw(eventprojectraw);
            }

            return result;
        }
Ejemplo n.º 4
0
        public RESULT getParentProject(ref EventProject project)
        {
            RESULT       result          = RESULT.OK;
            IntPtr       eventprojectraw = new IntPtr();
            EventProject eventprojectnew = null;

            try
            {
                result = FMOD_EventGroup_GetParentProject(eventgroupraw, ref eventprojectraw);
            }
            catch
            {
                result = RESULT.ERR_INVALID_PARAM;
            }
            if (result != RESULT.OK)
            {
                return result;
            }

            if (project == null)
            {
                eventprojectnew = new EventProject();
                eventprojectnew.setRaw(eventprojectraw);
                project = eventprojectnew;
            }
            else
            {
                project.setRaw(eventprojectraw);
            }

            return result;
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }