Skip to content
This repository has been archived by the owner on Nov 4, 2021. It is now read-only.

[Optimization] Optimize FindClosestBeaconInRange #7

Open
AlexMog opened this issue Feb 20, 2021 · 0 comments
Open

[Optimization] Optimize FindClosestBeaconInRange #7

AlexMog opened this issue Feb 20, 2021 · 0 comments

Comments

@AlexMog
Copy link
Owner

AlexMog commented Feb 20, 2021

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;
	}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant