Longship icon indicating copy to clipboard operation
Longship copied to clipboard

[Optimization] Optimize FindClosestBeaconInRange

Open AlexMog opened this issue 4 years ago • 0 comments

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

AlexMog avatar Feb 20 '21 04:02 AlexMog