Пример #1
0
    public static void MarkFrequencyDirty(int frequency)
    {
        frequency = RFManager.ClampFrequency(frequency);
        List <IRFObject> broadcasterList = RFManager.GetBroadcasterList(frequency);
        List <IRFObject> listenList      = RFManager.GetListenList(frequency);
        bool             on    = broadcasterList.Count > 0;
        bool             flag1 = false;
        bool             flag2 = false;

        foreach (IRFObject rfObject1 in listenList)
        {
            if (!rfObject1.IsValidEntityReference <IRFObject>())
            {
                flag1 = true;
            }
            else
            {
                if (on)
                {
                    on = false;
                    foreach (IRFObject rfObject2 in broadcasterList)
                    {
                        if (!rfObject2.IsValidEntityReference <IRFObject>())
                        {
                            flag2 = true;
                        }
                        else if ((double)Vector3.Distance(rfObject2.GetPosition(), rfObject1.GetPosition()) <= (double)rfObject2.GetMaxRange())
                        {
                            on = true;
                            break;
                        }
                    }
                }
                rfObject1.RFSignalUpdate(on);
            }
        }
        if (flag1)
        {
            Debug.LogWarning((object)("Found null entries in the RF listener list for frequency " + (object)frequency + "... cleaning up."));
            for (int index = listenList.Count - 1; index >= 0; --index)
            {
                if (listenList[index] == null)
                {
                    listenList.RemoveAt(index);
                }
            }
        }
        if (!flag2)
        {
            return;
        }
        Debug.LogWarning((object)("Found null entries in the RF broadcaster list for frequency " + (object)frequency + "... cleaning up."));
        for (int index = broadcasterList.Count - 1; index >= 0; --index)
        {
            if (broadcasterList[index] == null)
            {
                broadcasterList.RemoveAt(index);
            }
        }
    }
Пример #2
0
        /*
         * Callback function getting called by the listener loop timer
         */
        private void CheckListeners()
        {
            this.LogDebug(lang.GetMessage("debug_checklisteners", this, ""));

            // Iterate over every configured listener
            for (int i = 0; i < this.config_data.configured_listeners.Count; i++)
            {
                // Make sure listener is currently not blocked
                if (!this.config_data.configured_listeners[i].IsBlocked())
                {
                    // Check if broadcasters on the listeners configured frequency are currently active
                    var broadcasters = RFManager.GetBroadcasterList(this.config_data.configured_listeners[i].GetFrequency());
                    if (broadcasters.Count > 0)
                    {
                        this.Log(this.config_data.configured_listeners[i].GetMessage());
                        // Enable blocking for next loop(s) if configured
                        this.config_data.configured_listeners[i].EnableBlocking();
                    }
                }
                else
                {
                    this.LogDebug(string.Format(lang.GetMessage("debug_listenerblocked", this, ""), this.config_data.configured_listeners[i].GetFrequency()));
                }
            }
        }
Пример #3
0
    public static void RemoveBroadcaster(int frequency, IRFObject obj)
    {
        frequency = RFManager.ClampFrequency(frequency);
        List <IRFObject> broadcasterList = RFManager.GetBroadcasterList(frequency);

        if (broadcasterList.Contains(obj))
        {
            broadcasterList.Remove(obj);
        }
        RFManager.MarkFrequencyDirty(frequency);
    }
Пример #4
0
    public static void AddBroadcaster(int frequency, IRFObject obj)
    {
        frequency = RFManager.ClampFrequency(frequency);
        List <IRFObject> broadcasterList = RFManager.GetBroadcasterList(frequency);

        if (broadcasterList.Contains(obj))
        {
            return;
        }
        broadcasterList.Add(obj);
        RFManager.MarkFrequencyDirty(frequency);
    }
Пример #5
0
 void RfToolInspect(IPlayer player, string command, string[] args)
 {
     for (int cur_freq = frequency_min; cur_freq <= frequency_max; cur_freq++)
     {
         var listeners = RFManager.GetListenList(cur_freq);
         if (listeners.Count > 0)
         {
             this.ReplyToPlayer(player, string.Format(lang.GetMessage("cmd_rftool.inspect_listeners", this, player.Id), listeners.Count, cur_freq));
         }
     }
     for (int cur_freq = frequency_min; cur_freq <= frequency_max; cur_freq++)
     {
         var broadcasters = RFManager.GetBroadcasterList(cur_freq);
         if (broadcasters.Count > 0)
         {
             this.ReplyToPlayer(player, string.Format(lang.GetMessage("cmd_rftool.inspect_broadcaster", this, player.Id), broadcasters.Count, cur_freq));
         }
     }
 }
Пример #6
0
    public static void MarkFrequencyDirty(int frequency)
    {
        frequency = RFManager.ClampFrequency(frequency);
        List <IRFObject> broadcasterList = RFManager.GetBroadcasterList(frequency);
        List <IRFObject> listenList      = RFManager.GetListenList(frequency);
        bool             count           = broadcasterList.Count > 0;
        bool             flag            = false;
        bool             flag1           = false;

        foreach (IRFObject rFObject in listenList)
        {
            if (rFObject.IsValidEntityReference <IRFObject>())
            {
                if (count)
                {
                    count = false;
                    foreach (IRFObject rFObject1 in broadcasterList)
                    {
                        if (rFObject1.IsValidEntityReference <IRFObject>())
                        {
                            if (Vector3.Distance(rFObject1.GetPosition(), rFObject.GetPosition()) > rFObject1.GetMaxRange())
                            {
                                continue;
                            }
                            count = true;
                            goto Label0;
                        }
                        else
                        {
                            flag1 = true;
                        }
                    }
                }
Label0:
                rFObject.RFSignalUpdate(count);
            }
            else
            {
                flag = true;
            }
        }
        if (flag)
        {
            Debug.LogWarning(string.Concat("Found null entries in the RF listener list for frequency ", frequency, "... cleaning up."));
            for (int i = listenList.Count - 1; i >= 0; i--)
            {
                if (listenList[i] == null)
                {
                    listenList.RemoveAt(i);
                }
            }
        }
        if (flag1)
        {
            Debug.LogWarning(string.Concat("Found null entries in the RF broadcaster list for frequency ", frequency, "... cleaning up."));
            for (int j = broadcasterList.Count - 1; j >= 0; j--)
            {
                if (broadcasterList[j] == null)
                {
                    broadcasterList.RemoveAt(j);
                }
            }
        }
    }