Exemplo n.º 1
0
 public static void Select(SelectableComponent selectableComponent, SelectionCriteria selectionCriteria = null)
 {
     if (!selectableComponent.isSelected && IsValidSelection(selectionCriteria, selectableComponent))
     {
         selectableComponent.Select();
     }
 }
Exemplo n.º 2
0
 public static void Deselect(SelectableComponent selectableComponent)
 {
     if (selectableComponent.isSelected)
     {
         selectableComponent.Deselect();
     }
 }
Exemplo n.º 3
0
        public static void RemoveSelectable(SelectableComponent selectableComponent)
        {
            int id = selectableComponent.Guid;

            if (_selectionListeners.ContainsKey(id))
            {
                _selectionListeners.Remove(id);
            }
        }
Exemplo n.º 4
0
        public static void AddSelectable(SelectableComponent selectableComponent)
        {
            int id = selectableComponent.Guid;

            if (!_selectionListeners.ContainsKey(id))
            {
                _selectionListeners.Add(id, selectableComponent.selectionListener);
            }
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
 public SelectionListener(SelectableComponent selectableComponent)
 {
     this.SelectableComponent = selectableComponent;
 }