상속: IAgent
예제 #1
0
 public float InsertAgentNeighbour(Agent agent, float rangeSq)
 {
     if (this == agent)
     {
         return rangeSq;
     }
     if ((agent.layer & this.collidesWith) == (RVOLayer)0)
     {
         return rangeSq;
     }
     float num = this.Sqr(agent.position.x - this.position.x) + this.Sqr(agent.position.z - this.position.z);
     if (num < rangeSq)
     {
         if (this.neighbours.Count < this.maxNeighbours)
         {
             this.neighbours.Add(agent);
             this.neighbourDists.Add(num);
         }
         int num2 = this.neighbours.Count - 1;
         if (num < this.neighbourDists[num2])
         {
             while (num2 != 0 && num < this.neighbourDists[num2 - 1])
             {
                 this.neighbours[num2] = this.neighbours[num2 - 1];
                 this.neighbourDists[num2] = this.neighbourDists[num2 - 1];
                 num2--;
             }
             this.neighbours[num2] = agent;
             this.neighbourDists[num2] = num;
         }
         if (this.neighbours.Count == this.maxNeighbours)
         {
             rangeSq = this.neighbourDists[this.neighbourDists.Count - 1];
         }
     }
     return rangeSq;
 }
예제 #2
0
 private Vector2 Trace(Agent.VO[] vos, int voCount, Vector2 p, float cutoff, out float score)
 {
     score = 0f;
     float stepScale = this.simulator.stepScale;
     float num = float.PositiveInfinity;
     Vector2 result = p;
     for (int i = 0; i < 50; i++)
     {
         float num2 = 1f - (float)i / 50f;
         num2 *= stepScale;
         Vector2 vector = Vector2.zero;
         float num3 = 0f;
         for (int j = 0; j < voCount; j++)
         {
             float num4;
             Vector2 b = vos[j].Sample(p, out num4);
             vector += b;
             if (num4 > num3)
             {
                 num3 = num4;
             }
         }
         Vector2 a = new Vector2(this.desiredVelocity.x, this.desiredVelocity.z) - p;
         float val = a.magnitude * Agent.DesiredVelocityWeight;
         vector += a * Agent.DesiredVelocityScale;
         num3 = Math.Max(num3, val);
         score = num3;
         if (score < num)
         {
             num = score;
         }
         result = p;
         if (score <= cutoff && i > 10)
         {
             break;
         }
         float sqrMagnitude = vector.sqrMagnitude;
         if (sqrMagnitude > 0f)
         {
             vector *= num3 / Mathf.Sqrt(sqrMagnitude);
         }
         vector *= num2;
         Vector2 p2 = p;
         p += vector;
         if (this.DebugDraw)
         {
             UnityEngine.Debug.DrawLine(Agent.To3D(p2) + this.position, Agent.To3D(p) + this.position, Agent.Rainbow(0.1f / score) * new Color(1f, 1f, 1f, 0.2f));
         }
     }
     score = num;
     return result;
 }
예제 #3
0
        // Token: 0x060028F5 RID: 10485 RVA: 0x001BA630 File Offset: 0x001B8830
        private Vector2 Trace(Agent.VOBuffer vos, Vector2 p, out float score)
        {
            float   num    = Mathf.Max(this.radius, 0.2f * this.desiredSpeed);
            float   num2   = float.PositiveInfinity;
            Vector2 result = p;

            for (int i = 0; i < 50; i++)
            {
                float num3 = 1f - (float)i / 50f;
                num3 = Agent.Sqr(num3) * num;
                float   num4;
                Vector2 vector = this.EvaluateGradient(vos, p, out num4);
                if (num4 < num2)
                {
                    num2   = num4;
                    result = p;
                }
                vector.Normalize();
                vector *= num3;
                Vector2 a = p;
                p += vector;
                if (this.DebugDraw)
                {
                    Debug.DrawLine(Agent.FromXZ(a + this.position), Agent.FromXZ(p + this.position), Agent.Rainbow((float)i * 0.1f) * new Color(1f, 1f, 1f, 1f));
                }
            }
            score = num2;
            return(result);
        }