Пример #1
0
            public void Update(float deltaTime, Matrix world)
            {
                if (!(GameDataManager.GameType == GameDataManager.GameTypes.DS1 ||
                      GameDataManager.GameType == GameDataManager.GameTypes.DS1R ||
                      GameDataManager.GameType == GameDataManager.GameTypes.DS3 ||
                      GameDataManager.GameType == GameDataManager.GameTypes.SDT))
                {
                    return;
                }

                FMOD.EVENT_STATE state = EVENT_STATE.PLAYING;
                evtRes = Event.getState(ref state);

                if (evtRes == RESULT.ERR_INVALID_HANDLE)
                {
                    EventIsOver = true;
                    return;
                }

                if (state == EVENT_STATE.READY)
                {
                    EventIsOver = true;
                }
                else
                {
                    var position = Vector3.Transform(((GetPosFunc?.Invoke() ?? Vector3.Zero) * new Vector3(1, 1, 1)), world);
                    var velocity = Vector3.Zero;// (position - oldPos) / deltaTime;

                    // Flatten position to be on a flat plane
                    //position.Y = 0;

                    FMOD.VECTOR posVec = new VECTOR(position);
                    FMOD.VECTOR velVec = new VECTOR(velocity);

                    // If it fails due to the event being released, it's fine. No weirdness should happen.
                    evtRes = Event.set3DAttributes(ref posVec, ref velVec);
                    evtRes = Event.setVolume(BaseSoundVolume * AdjustSoundVolume);

                    oldPos = position;
                }
            }
Пример #2
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);
        }
Пример #3
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);
        }