Hey there,
I was wondering if I could use a LINQ Statement to get the closest entry from a list of objects, that is also matching another requirement.
To get the closest object, I’m using this statement:
private Builder GetClosestBuilder()
{
return BuildingManager.Instance._builders
.OrderBy(x => Vector3.Distance(x.transform.position, this.transform.position)).ToList()[0];
}
Is there a possibility to add something like a WHERE clause right into it or do i need to separate these steps?
In this example, I want to find the closest builder that is not busy (builder.busy == false)