private SmartEntity TraverseSpiralToFindTarget(int radius, int centerX, int centerZ, TargetingController.TargetValidator validator, object caller) { List <SmartEntity> list = TargetingController.TraverseSpiralToFindTargets(radius, centerX, centerZ, validator, caller, true); if (list != null && list.Count > 0) { return(list[0]); } return(null); }
public static List <SmartEntity> TraverseSpiralToFindTargets(int radius, int centerX, int centerZ, TargetingController.TargetValidator validator, object caller, bool returnFirstFound) { BoardCellDynamicArray boardCellDynamicArray = GameUtils.TraverseSpiral(radius, centerX, centerZ); List <SmartEntity> list = new List <SmartEntity>(); for (int i = 0; i < boardCellDynamicArray.Length; i++) { BoardCell boardCell = boardCellDynamicArray.Array[i]; if (boardCell.Children != null) { foreach (BoardItem current in boardCell.Children) { if (validator((SmartEntity)current.Data, caller)) { list.Add((SmartEntity)current.Data); if (returnFirstFound) { return(list); } } } } } return(list); }
public static List <SmartEntity> TraverseSpiralToFindTargets(int radius, int centerX, int centerZ, TargetingController.TargetValidator validator, object caller, bool returnFirstFound) { List <BoardCell <Entity> > list = GameUtils.TraverseSpiral(radius, centerX, centerZ); List <SmartEntity> list2 = new List <SmartEntity>(); if (list != null) { foreach (BoardCell <Entity> current in list) { if (current.Children != null) { using (IEnumerator <BoardItem <Entity> > enumerator2 = current.Children.GetEnumerator()) { while (enumerator2.MoveNext()) { BoardItem <Entity> current2 = enumerator2.get_Current(); if (validator((SmartEntity)current2.Data, caller)) { list2.Add((SmartEntity)current2.Data); if (returnFirstFound) { return(list2); } } } } } } return(list2); } return(list2); }