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);
}