Esempio n. 1
0
    IEnumerator QueryCommandables(FindCommandableQueryRequest request)
    {
        List<Commandable> commandables = new List<Commandable>();

        foreach (var collider in Physics2D.OverlapCircleAll(request.location, request.radius, Instance.unitLayer))
        {
            var unit = collider.gameObject.GetComponent<Commandable>();
            if (unit == null)
            {
                continue;
            }
            if (unit.Faction == request.faction)
            {
                commandables.Add(unit);
            }
        }
        yield return null;
        if(request.CallBack.Target != null || request.CallBack != null)
        {
            request.CallBack(commandables);
        }
        Instance.IsProcessingCommandableQuery = false;
        Instance.TryProcessNextFindCommandable();
    }
Esempio n. 2
0
 public static void FindCommandablesInRange(Faction faction, Vector2 location, float radius, Action<List<Commandable>> CallBack)
 {
     FindCommandableQueryRequest request = new FindCommandableQueryRequest(faction, location, radius, CallBack);
     Instance.FindCommandableQueryQueue.Enqueue(request);
     Instance.TryProcessNextFindCommandable();
 }