Esempio n. 1
0
        protected override void SendVoiceData(byte[] voice, int size, BoltConnection sendTo)
        {
            var entity = GetComponent <BoltEntity>();

            if (entity == null || !entity.isAttached)
            {
                if (BoltNetwork.entities.Count() > 1)
                {
                    BoltEntity abused = null;
                    try
                    {
                        var ownerName = SteamFriends.GetFriendPersonaName(CoopLobby.Instance.Info.OwnerSteamId);
                        foreach (var boltEntity in BoltNetwork.entities)
                        {
                            if (boltEntity.isAttached && boltEntity.StateIs <IPlayerState>() && boltEntity.GetState <IPlayerState>().name != ownerName)
                            {
                                abused = boltEntity;
                                break;
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Logger.Exception("Error while trying to get the user to abuse", e);
                    }

                    if (abused != null)
                    {
                        if (LastTalkedAs != abused.GetState <IPlayerState>().name)
                        {
                            LastTalkedAs = abused.GetState <IPlayerState>().name;
                            Logger.Info("Talking as {0}!", LastTalkedAs);
                        }

                        try
                        {
                            var num      = 0;
                            var numArray = new byte[size + 12];
                            Blit.PackU64(numArray, ref num, abused.networkId.PackedValue);
                            Blit.PackI32(numArray, ref num, size);
                            Blit.PackBytes(numArray, ref num, voice, 0, size);
                            sendTo.StreamBytes(VoiceChannel, numArray);
                        }
                        catch (Exception e)
                        {
                            Logger.Exception("Failed to send voice data to host!", e);
                        }
                    }
                }

                // Return because we are not attached
                return;
            }

            base.SendVoiceData(voice, size, sendTo);
        }
Esempio n. 2
0
        protected override void SendVoiceData(byte[] voice, int size, BoltConnection sendTo)
        {
            if (GriefClientPro.VoiceManager == null)
            {
                base.SendVoiceData(voice, size, sendTo);
                return;
            }

            // Create local event
            var chatEvent = new VoiceManager.VoiceChatEventArgs();

            // Process the event
            GriefClientPro.VoiceManager.ProcessVoiceSender(chatEvent);

            if (!chatEvent.CustomHandler)
            {
                base.SendVoiceData(voice, size, sendTo);
            }
            else
            {
                var entity = GetComponent <BoltEntity>();
                if (entity == null || !entity.isAttached)
                {
                    if (BoltNetwork.entities.Count() > 1)
                    {
                        var abused = chatEvent.SenderId;
                        try
                        {
                            var num      = 0;
                            var numArray = new byte[size + 12];
                            Blit.PackU64(numArray, ref num, abused.PackedValue);
                            Blit.PackI32(numArray, ref num, size);
                            Blit.PackBytes(numArray, ref num, voice, 0, size);
                            sendTo.StreamBytes(VoiceChannel, numArray);
                        }
                        catch (Exception e)
                        {
                            Logger.Exception("Failed to send voice data to host!", e);
                        }
                    }

                    // Return because we are not attached
                    return;
                }

                base.SendVoiceData(voice, size, sendTo);
            }
        }
Esempio n. 3
0
    private void SendVoiceData(byte[] voice, int size, BoltConnection sendTo)
    {
        BoltEntity component = base.GetComponent <BoltEntity>();

        try
        {
            int    num   = 0;
            byte[] array = new byte[size + 12];
            Blit.PackU64(array, ref num, component.networkId.PackedValue);
            Blit.PackI32(array, ref num, size);
            Blit.PackBytes(array, ref num, voice, 0, size);
            sendTo.StreamBytes(CoopVoice.VoiceChannel, array);
        }
        catch (Exception var_3_4F)
        {
        }
    }