Esempio n. 1
0
 private void process()
 {
     if (Time.frameCount % UpdateRateDivisor != 0)
     {
         return;
     }
     Profiler.BeginSample("Proximity Processing");
     for (int i = 0; i < groupKeys.Count; i++)
     {
         Group group = Groups[groupKeys[i]];
         distancesSquared.Clear();
         for (int j = 0; j < group.Broadcasters.Count; j++)
         {
             float distance = group.Broadcasters[j].Distance;
             distancesSquared.Add(distance * distance);
         }
         for (int j = 0; j < group.Listeners.Count; j++)
         {
             ProximityListener proximityListener = group.Listeners[j];
             Vector3           position          = proximityListener.transform.position;
             List <bool>       list = group.BroadcastersInRange[j];
             while (list.Count < group.Broadcasters.Count)
             {
                 list.Add(item: false);
             }
             for (int k = 0; k < group.Broadcasters.Count; k++)
             {
                 ProximityBroadcaster proximityBroadcaster = group.Broadcasters[k];
                 float sqrMagnitude = (position - (proximityBroadcaster.transform.position + proximityBroadcaster.Offset)).sqrMagnitude;
                 bool  flag         = sqrMagnitude < distancesSquared[k];
                 if (flag)
                 {
                     if (list[k])
                     {
                         proximityListener.OnProximityStay(proximityBroadcaster);
                         proximityBroadcaster.OnProximityStay(proximityListener);
                     }
                     else
                     {
                         proximityListener.OnProximityEnter(proximityBroadcaster);
                         proximityBroadcaster.OnProximityEnter(proximityListener);
                     }
                 }
                 else if (list[k])
                 {
                     proximityListener.OnProximityExit(proximityBroadcaster);
                     proximityBroadcaster.OnProximityExit(proximityListener);
                 }
                 list[k] = flag;
             }
         }
     }
     Profiler.EndSample();
 }
Esempio n. 2
0
        public void RemoveBroadcaster(ProximityBroadcaster broadcaster)
        {
            Group group = getGroup(broadcaster.ProximityGroup);

            group.Broadcasters.Remove(broadcaster);
        }
 public virtual void OnProximityExit(ProximityBroadcaster other)
 {
 }
Esempio n. 4
0
        public void AddBroadcaster(ProximityBroadcaster broadcaster)
        {
            Group group = getGroup(broadcaster.ProximityGroup);

            group.Broadcasters.Add(broadcaster);
        }
 public virtual void OnProximityStay(ProximityBroadcaster other)
 {
 }