示例#1
0
        public void AfterRollbackAwareFrame(IAudioDefinitions definitions)
        {
            Debug.Assert(rollbackAware);

            if (doingPrediction)
            {
                if (activeFrame == liveFrame)                 // Completed re-simulation of rollback frames
                {
                    doingPrediction = false;

                    foreach (var pending in pendingCues)
                    {
                        if (!TryKillCueFuzzy(pending.cue, activeFrame, pending.position))
                        {
                            if (!doingStartupPrediction)
                            {
                                SoundEffectManager.PlayCueSkipMissingCheck(definitions, pending.cue, pending.parameters,
                                                                           pending.fpp);
                            }
                            AddLiveCueNow(pending.cue, pending.position);
                        }
                    }

                    pendingCues.Clear();
                }
            }
        }
示例#2
0
        public void PlayCueSkipMissingCheck(IAudioDefinitions definitions, Cue cue, Position?worldPosition, FadePitchPan fpp,
                                            PlayCueParameters parameters, bool playsLocally)
        {
            if (parameters.soundIndex < 0)
            {
                return;
            }


            if (!playsLocally || !AudioDevice.Available)
            {
                return;                                       // <- nothing to do!
            }
            if (doingPrediction)                              // Re-prediction following rollback
            {
                if (activeFrame >= liveFrame - DontCareLimit) // <- new enough that we could still be tracking it
                {
                    if (!TryKillCueExact(cue, activeFrame, worldPosition))
                    {
                        if (activeFrame >= liveFrame - MaximumSoundShift)                     // <- new enough that we may play it
                        {
                            PendingCue pending;
                            pending.cue        = cue;
                            pending.parameters = parameters;
                            pending.frame      = activeFrame;
                            pending.position   = worldPosition;
                            pending.fpp        = fpp;

                            pendingCues.Add(pending);
                        }
                    }
                }
            }
            else         // Standard playback
            {
                Debug.Assert(activeFrame == liveFrame);

                if (!rollbackAware || !TryKillCueFuzzy(cue, activeFrame, worldPosition))
                {
                    if (!doingStartupPrediction)
                    {
                        SoundEffectManager.PlayCueSkipMissingCheck(definitions, cue, parameters, fpp);
                    }
                    AddLiveCueNow(cue, worldPosition);
                }
            }
        }