public static void Select(SelectableComponent selectableComponent, SelectionCriteria selectionCriteria = null) { if (!selectableComponent.isSelected && IsValidSelection(selectionCriteria, selectableComponent)) { selectableComponent.Select(); } }
public static void Deselect(SelectableComponent selectableComponent) { if (selectableComponent.isSelected) { selectableComponent.Deselect(); } }
public static void RemoveSelectable(SelectableComponent selectableComponent) { int id = selectableComponent.Guid; if (_selectionListeners.ContainsKey(id)) { _selectionListeners.Remove(id); } }
public static void AddSelectable(SelectableComponent selectableComponent) { int id = selectableComponent.Guid; if (!_selectionListeners.ContainsKey(id)) { _selectionListeners.Add(id, selectableComponent.selectionListener); } }
public static bool IsValidSelection(SelectionCriteria criteria, SelectableComponent selectableComponent) { if (criteria is null) { return(true); } bool valid = criteria._isAgent == selectableComponent.entity.isAgent; valid = criteria._op(valid, criteria._isBuilding == selectableComponent.entity.isStructure); //valid = criteria.op(valid, criteria.isControllable != selectable.gameObject.GetComponent<Owner>()); return(valid); }
public SelectionListener(SelectableComponent selectableComponent) { this.SelectableComponent = selectableComponent; }