public IEnumerable GetTargetFilter(ActionTarget target)
    {
        foreach(KeyValuePair<UnitType, HashSet<UnitEntity>> key in mUnitsByType) {
            foreach(UnitEntity unit in key.Value) {
                ActionListener listener = unit.listener;
                if(!listener.lockAction && target.vacancy && listener.currentPriority <= target.priority) {
                    switch(target.type) {
                    case ActionType.Attack:
                        StatBase targetStats = target.GetComponentInChildren<StatBase>();
                        if(targetStats == null || unit.stats.CanDamage(targetStats)) {
                            yield return unit;
                        }
                        break;

                    default:
                        yield return unit;
                        break;
                    }
                }
            }
        }
    }
    public IEnumerable GetTargetFilter(UnitType type, ActionTarget target)
    {
        HashSet<UnitEntity> units;
        if(mUnitsByType.TryGetValue(type, out units)) {

            foreach(UnitEntity unit in units) {
                ActionListener listener = unit.listener;
                if(target.vacancy && listener.currentPriority <= target.priority) {
                    switch(target.type) {
                    case ActionType.Attack:
                        StatBase targetStats = target.GetComponentInChildren<StatBase>();
                        if(targetStats == null || unit.stats.CanDamage(targetStats)) {
                            yield return unit;
                        }
                        break;

                    default:
                        yield return unit;
                        break;
                    }
                }
            }
        }
    }