Exemplo n.º 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);
            }
        }
    }
Exemplo n.º 2
0
 public static void ChangeFrequency(
     int oldFrequency,
     int newFrequency,
     IRFObject obj,
     bool isListener,
     bool isOn = true)
 {
     newFrequency = RFManager.ClampFrequency(newFrequency);
     if (isListener)
     {
         RFManager.RemoveListener(oldFrequency, obj);
         if (!isOn)
         {
             return;
         }
         RFManager.AddListener(newFrequency, obj);
     }
     else
     {
         RFManager.RemoveBroadcaster(oldFrequency, obj);
         if (!isOn)
         {
             return;
         }
         RFManager.AddBroadcaster(newFrequency, obj);
     }
 }
Exemplo n.º 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);
    }
Exemplo n.º 4
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);
    }
Exemplo n.º 5
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);
    }
Exemplo n.º 6
0
    public static List <IRFObject> GetBroadcasterList(int frequency)
    {
        frequency = RFManager.ClampFrequency(frequency);
        List <IRFObject> rfObjectList = (List <IRFObject>)null;

        if (!RFManager._broadcasters.TryGetValue(frequency, out rfObjectList))
        {
            rfObjectList = new List <IRFObject>();
            RFManager._broadcasters.Add(frequency, rfObjectList);
        }
        return(rfObjectList);
    }
Exemplo n.º 7
0
    public static List <IRFObject> GetListenList(int frequency)
    {
        frequency = RFManager.ClampFrequency(frequency);
        List <IRFObject> rFObjects = null;

        if (!RFManager._listeners.TryGetValue(frequency, out rFObjects))
        {
            rFObjects = new List <IRFObject>();
            RFManager._listeners.Add(frequency, rFObjects);
        }
        return(rFObjects);
    }
Exemplo n.º 8
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);
    }
Exemplo n.º 9
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);
                }
            }
        }
    }