find_entities_filtered with position, radius and limit
Posted: Tue Jun 01, 2021 2:36 pm
Given a position, radius and limit, which entities are returned?
Does the function scan outward from the position until it finds enough entities, at which point it returns the N closest matching entities? Or does it compute the area to search based on position and radius and return whatever N matching entities it happens to find in there?
Use case: I'd like to search for up to 10 of a type of entity within a radius of the player. If the function scans outwards from the position, then I can just use find_entities_filtered without any worry. But if it's arbitrary, then I would need to find all matching entities, sort them by distance and take the 10 closest manually.
I can absolutely do that, of course, but if the function already guarantees the 10 closest, it's redundant to code that myself.
Does the function scan outward from the position until it finds enough entities, at which point it returns the N closest matching entities? Or does it compute the area to search based on position and radius and return whatever N matching entities it happens to find in there?
Use case: I'd like to search for up to 10 of a type of entity within a radius of the player. If the function scans outwards from the position, then I can just use find_entities_filtered without any worry. But if it's arbitrary, then I would need to find all matching entities, sort them by distance and take the 10 closest manually.
I can absolutely do that, of course, but if the function already guarantees the 10 closest, it's redundant to code that myself.