Longship
Longship copied to clipboard
[Optimization] Optimize FindClosestBeaconInRange
Same as #6 but with Beacons.
I'm not sure that code is used frequently, need more investigation.
Class: Beacon
public static Beacon FindClosestBeaconInRange(Vector3 point)
{
Beacon beacon = null;
float num = 999999f;
foreach (Beacon instance in m_instances)
{
float num2 = Vector3.Distance(point, instance.transform.position);
if (num2 < instance.m_range && (beacon == null || num2 < num))
{
beacon = instance;
num = num2;
}
}
return beacon;
}