コード例 #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
        void RfToolDisable(IPlayer player, string command, string[] args)
        {
            int frequency = 0;

            // Check if player specified a frequency
            if (args.Length != 1)
            {
                this.ReplyToPlayer(player, string.Format(lang.GetMessage("cmd_rftool.disable_help", this, player.Id), this.frequency_min, this.frequency_max));
                return;
            }

            // Get & check frequency
            frequency = this.GetFrequency(player, args);
            if (frequency == 0)
            {
                return;
            }

            // Get all listeners for given frequency and disable them
            var listeners = RFManager.GetListenList(frequency);

            for (int i = 0; i < listeners.Count; i++)
            {
                listeners[i].RFSignalUpdate(false);
            }

            this.ReplyToPlayer(player, string.Format(lang.GetMessage("cmd_rftool.disable_success", this, player.Id), listeners.Count, frequency));
        }
コード例 #3
0
    public static void RemoveListener(int frequency, IRFObject obj)
    {
        frequency = RFManager.ClampFrequency(frequency);
        List <IRFObject> listenList = RFManager.GetListenList(frequency);

        if (listenList.Contains(obj))
        {
            listenList.Remove(obj);
        }
        obj.RFSignalUpdate(false);
    }
コード例 #4
0
    public static void AddListener(int frequency, IRFObject obj)
    {
        frequency = RFManager.ClampFrequency(frequency);
        List <IRFObject> listenList = RFManager.GetListenList(frequency);

        if (listenList.Contains(obj))
        {
            Debug.Log("adding same listener twice");
            return;
        }
        listenList.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);
                }
            }
        }
    }