public bool CalculateAvailableNearestTree(Villager inVillager, out TreeScript nearestTree) { if (!AreAvailableTreesInSanctuary()) { nearestTree = null; return(false); } foreach (var tree in TreesPriorityQueue) { var distance = (inVillager.transform.position - tree.transform.position).magnitude; TreesPriorityQueue.UpdatePriority(tree, distance); } var treesArray = TreesPriorityQueue.ToArray(); for (var i = 0; i < treesArray.Length; i++) { if (!treesArray[i].isOccupied) { nearestTree = treesArray[i]; return(true); } } inVillager.UpdateAIText("No Available Trees"); nearestTree = null; return(false); }
public int[] GetFrontier() { return(frontier.ToArray()); }