Beispiel #1
0
 private void SelectByPriority()
 {
     // We could make this generic using type reflection, however that would make the code substantially more confusing
     if (SelectionHelper.ContainsAny <Unit>(hoverTargets) || SelectionHelper.ContainsOnly <Unit>(selection))
     {
         List <Unit> selectedUnits = SelectionHelper.ConvertAll <Interactable, Unit>(hoverTargets);
         selection.AddRange(selectedUnits);
         selection = selection.Distinct().ToList();
     }
     else if (SelectionHelper.ContainsAny <Building>(hoverTargets) || SelectionHelper.ContainsOnly <Building>(selection))
     {
         List <Building> selectedBuildings = SelectionHelper.ConvertAll <Interactable, Building>(hoverTargets);
         selection.AddRange(selectedBuildings);
         selection = selection.Distinct().ToList();
     }
     else if (SelectionHelper.ContainsAny <Resource>(hoverTargets) || SelectionHelper.ContainsOnly <Resource>(selection))
     {
         List <Resource> selectedResources = SelectionHelper.ConvertAll <Interactable, Resource>(hoverTargets);
         selection.AddRange(selectedResources);
         selection = selection.Distinct().ToList();
     }
 }