Exemple #1
0
        private bool CanReceive(Client sender, Client recipient)
        {
            if (Screen.Selected != GameMain.GameScreen)
            {
                return(true);
            }

            //no-one can hear muted players
            if (sender.Muted)
            {
                return(false);
            }

            bool recipientSpectating = recipient.Character == null || recipient.Character.IsDead;
            bool senderSpectating    = sender.Character == null || sender.Character.IsDead;

            //TODO: only allow spectators to hear the voice chat if close enough to the speaker?

            //non-spectators cannot hear spectators
            if (senderSpectating && !recipientSpectating)
            {
                return(false);
            }

            //both spectating, no need to do radio/distance checks
            if (recipientSpectating && senderSpectating)
            {
                return(true);
            }

            //spectators can hear non-spectators
            if (!senderSpectating && recipientSpectating)
            {
                return(true);
            }

            //sender can't speak
            //if (sender.Character != null && sender.Character.SpeechImpediment >= 100.0f) { return false; }

            //check if the message can be sent via radio
            if (!sender.VoipQueue.ForceLocal &&
                ChatMessage.CanUseRadio(sender.Character, out WifiComponent senderRadio) &&
                ChatMessage.CanUseRadio(recipient.Character, out WifiComponent recipientRadio))
            {
                //if (recipientRadio.CanReceive(senderRadio)) { return true; }
                WifiComponent test = senderRadio;
                test.Range = 2000.0f;
                if (recipientRadio.CanReceive(senderRadio))
                {
                    return(true);
                }
            }

            //otherwise do a distance check
            return(ChatMessage.GetGarbleAmount(recipient.Character, sender.Character, ChatMessage.SpeakRange) < 1.0f);
        }
Exemple #2
0
        private bool CanReceive(Client sender, Client recipient)
        {
            if (Screen.Selected != GameMain.GameScreen)
            {
                return(true);
            }

            //no-one can hear muted players
            if (sender.Muted)
            {
                return(false);
            }

            bool recipientSpectating = recipient.Character == null || recipient.Character.IsDead;
            bool senderSpectating    = sender.Character == null || sender.Character.IsDead;

            //spectators cannot speak with in-game players or vice versa
            //TODO: allow spectators to hear the voice chat if close enough to the speaker?
            if (recipientSpectating != senderSpectating)
            {
                return(false);
            }

            //both spectating, no need to do radio/distance checks
            if (recipientSpectating && senderSpectating)
            {
                return(true);
            }

            //sender can't speak
            if (sender.Character != null && sender.Character.SpeechImpediment >= 100.0f)
            {
                return(false);
            }

            //check if the message can be sent via radio
            if (ChatMessage.CanUseRadio(sender.Character, out WifiComponent senderRadio) &&
                ChatMessage.CanUseRadio(recipient.Character, out WifiComponent recipientRadio))
            {
                if (recipientRadio.CanReceive(senderRadio))
                {
                    return(true);
                }
            }

            //otherwise do a distance check
            return(ChatMessage.GetGarbleAmount(recipient.Character, sender.Character, ChatMessage.SpeakRange) < 1.0f);
        }