Пример #1
0
        private void dequeueStaleSpeech(EddiSpeech eddiSpeech)
        {
            // List EDDI event types of where stale event data should be removed in favor of more recent data
            string[] eventTypes = new string[]
            {
                "Cargo scoop",
                "Docking denied",
                "Docking requested",
                "Glide",
                "Hardpoints",
                "Next jump",
                "Heat damage",
                "Heat warning",
                "Hull damaged",
                "Landing gear",
                "Lights",
                "Near surface",
                "Silent running",
                "SRV turret deployable",
                "Under attack"
            };

            foreach (string eventType in eventTypes)
            {
                if (eddiSpeech.eventType == eventType)
                {
                    DequeueSpeechOfType(eventType);
                }
            }
        }
Пример #2
0
        public EddiSpeech GetSpeechFX(EddiSpeech speech)
        {
            Ship ship = speech.ship;

            speech.echoDelay        = echoDelayForShip(ship);
            speech.chorusLevel      = chorusLevelForShip(ship);
            speech.reverbLevel      = reverbLevelForShip(ship);
            speech.distortionLevel  = distortionLevelForShip(ship);
            speech.compressionLevel = 0;
            return(speech);
        }
Пример #3
0
 public void Enqueue(EddiSpeech speech)
 {
     if (speech == null)
     {
         return;
     }
     if (priorityQueues.ElementAtOrDefault(speech.priority) != null)
     {
         dequeueStaleSpeech(speech);
         priorityQueues[speech.priority].Enqueue(speech);
     }
 }
Пример #4
0
 public bool TryDequeue(out EddiSpeech speech)
 {
     speech = null;
     for (int i = 0; i < priorityQueues.Count; i++)
     {
         if (priorityQueues[i].TryDequeue(out EddiSpeech selectedSpeech))
         {
             speech = selectedSpeech;
             return(true);
         }
     }
     return(false);
 }
Пример #5
0
        public EddiSpeech(string message, Ship ship = null, int priority = 3, string voice = null, bool radio = false, string eventType = null)
        {
            this.message   = message;
            this.ship      = ship;
            this.priority  = priority;
            this.voice     = voice;
            this.radio     = radio;
            this.eventType = eventType;

            EddiSpeech speech = SpeechService.Instance.GetSpeechFX(this);

            this.echoDelay        = speech.echoDelay;
            this.chorusLevel      = speech.chorusLevel;
            this.reverbLevel      = speech.reverbLevel;
            this.distortionLevel  = speech.distortionLevel;
            this.compressionLevel = speech.compressionLevel;
        }
Пример #6
0
        public void Say(Ship ship, string message, int priority = 3, string voice = null, bool radio = false, string eventType = null, bool invokedFromVA = false)
        {
            if (message == null)
            {
                return;
            }

            if (ship == null)
            {
                // Provide basic ship definition
                ship = ShipDefinitions.FromModel("Sidewinder");
            }

            Thread speechQueueHandler = new Thread(() =>
            {
                // Queue the current speech
                EddiSpeech queuingSpeech = new EddiSpeech(message, ship, priority, voice, radio, eventType);
                speechQueue.Enqueue(queuingSpeech);

                // Check the first item in the speech queue
                if (speechQueue.TryPeek(out EddiSpeech peekedSpeech))
                {
                    // Interrupt current speech when appropriate
                    if (checkSpeechInterrupt(peekedSpeech.priority))
                    {
                        Logging.Debug("Interrupting current speech");
                        StopCurrentSpeech();
                    }
                }

                // Start or continue speaking from the speech queue
                Instance.StartOrContinueSpeaking();
            })
            {
                Name         = "SpeechQueueHandler",
                IsBackground = true
            };

            speechQueueHandler.Start();
            if (invokedFromVA)
            {
                // If invoked from VA, thread should terminate only after speech completes
                speechQueueHandler.Join();
            }
        }
Пример #7
0
        private void dequeueStaleSpeech(EddiSpeech eddiSpeech)
        {
            // List EDDI event types of where stale event data should be removed in favor of more recent data
            string[] eventTypes = new string[]
            {
                "Next jump",
                "Heat damage",
                "Heat warning",
                "Hull damaged",
                "Under attack"
            };

            foreach (string eventType in eventTypes)
            {
                if (eddiSpeech.eventType == eventType)
                {
                    DequeueSpeechOfType(eventType);
                }
            }
        }
Пример #8
0
 private void filterSpeechQueue(string type, ref ConcurrentQueue <EddiSpeech> speechQueue, EddiSpeech eddiSpeech)
 {
     if (!(eddiSpeech.eventType == type))
     {
         speechQueue.Enqueue(eddiSpeech);
     }
 }
Пример #9
0
 public void Speak(EddiSpeech speech)
 {
     Instance.Speak(speech.message, speech.voice, speech.echoDelay, speech.distortionLevel, speech.chorusLevel, speech.reverbLevel, speech.compressionLevel, speech.radio, speech.priority);
 }
Пример #10
0
 private void filterSpeechQueue(string type, ref ConcurrentQueue <EddiSpeech> speechQueue, EddiSpeech eddiSpeech)
 {
     if (!(bool)eddiSpeech?.eventType?.Contains(type))
     {
         speechQueue.Enqueue(eddiSpeech);
     }
 }