Beispiel #1
0
 private void CalculateAgentNeighbours()
 {
     for (int i = 0; i < this.agents.get_Count(); i++)
     {
         Agent agent = this.agents.get_Item(i);
         agent.neighbours.Clear();
         agent.neighbourDists.Clear();
     }
     for (int j = 0; j < this.agents.get_Count(); j++)
     {
         Agent agent2 = this.agents.get_Item(j);
         long  num    = (long)(agent2.neighbourDist.i * agent2.neighbourDist.i);
         for (int k = j + 1; k < this.agents.get_Count(); k++)
         {
             Agent agent3 = this.agents.get_Item(k);
             if (!agent2.locked || !agent3.locked)
             {
                 long num2 = (long)(agent3.neighbourDist.i * agent3.neighbourDist.i);
                 long num3 = agent2.position.XZSqrMagnitude(ref agent3.position);
                 if (num3 < num && !agent2.locked)
                 {
                     agent2.InsertNeighbour(agent3, num3);
                 }
                 if (num3 < num2 && !agent3.locked)
                 {
                     agent3.InsertNeighbour(agent2, num3);
                 }
             }
         }
     }
 }
Beispiel #2
0
 private void CalculateAgentNeighbours()
 {
     for (int i = 0; i < this.agents.Count; i++)
     {
         Agent agent = this.agents[i];
         agent.neighbours.Clear();
         agent.neighbourDists.Clear();
     }
     for (int j = 0; j < this.agents.Count; j++)
     {
         Agent agent2 = this.agents[j];
         long  num3   = agent2.neighbourDist.i * agent2.neighbourDist.i;
         for (int k = j + 1; k < this.agents.Count; k++)
         {
             Agent agent3 = this.agents[k];
             if (!agent2.locked || !agent3.locked)
             {
                 long num5   = agent3.neighbourDist.i * agent3.neighbourDist.i;
                 long distSq = agent2.position.XZSqrMagnitude(ref agent3.position);
                 if ((distSq < num3) && !agent2.locked)
                 {
                     agent2.InsertNeighbour(agent3, distSq);
                 }
                 if ((distSq < num5) && !agent3.locked)
                 {
                     agent3.InsertNeighbour(agent2, distSq);
                 }
             }
         }
     }
 }