示例#1
0
        private void ProcessSelectionArea()
        {
            // If selecting with mouse pointer only (no box selection)
            if (!_isBoxSelecting)
            {
                var selectedObjects = SelectionManager.GetSelectedObjects();

                try
                {
                    if (selectedObjects.Count == 1)
                    {
                        var selectedObject = selectedObjects[0];
                        var entity         = EntityManager.GetEntityInParent(selectedObject);

                        if (entity != null)
                        {
                            _uiManager.OnSelectEntity(entity);
                        }
                    }
                    else if (selectedObjects.Count == 0)
                    {
                        SelectionManager.UpdateMouseSelection(_mouseOverObject, null);
                    }
                }
                catch (MissingReferenceException e)
                {
                    // if object gets destroyed, it may still be referenced here if selection manager doesnt update 'currently selected'
                    Debug.Log("Warning: trying to inspect a destroyed object.");
                    SelectionManager.CheckMissingSelected(); // TODO: optionally remove this
                }

                return;
            }

            if (_startedBoxSelection)
            {
                _startedBoxSelection = false;
                OnDeselectObjects();
            }

            // placeholder selection
            var selectionCriteria = new SelectionCriteria(
                isAgent: true,
                isBuilding: false,
                isControllable: true,
                SelectionCriteria.ECondition.Or,
                gameSession.CurrentPlayer.ownership.info
                );

            // TODO ADD CRITERIA/SORTING of selected objects

            SelectionManager.UpdateSelected(
                _mousePositionAtSelectionStart, _mousePositionAtSelectionEnd,
                _mouseOverObject, selectionCriteria);
        }