Esempio n. 1
0
        internal bool Pick <NodeType>(Vector2 screenPosition, out Cv_EntityID[] entities, Cv_Renderer renderer) where NodeType : Cv_SceneNode
        {
            var entityList     = new List <Cv_EntityID>();
            var scaledPosition = renderer.ScaleScreenToViewCoordinates(screenPosition);
            var result         = false;

            if (scaledPosition.X >= 0 && scaledPosition.X <= renderer.Viewport.Width &&
                scaledPosition.Y >= 0 && scaledPosition.Y <= renderer.Viewport.Height)
            {
                m_TransformStack.Clear();
                result = m_Root.Pick <NodeType>(renderer, scaledPosition, entityList);
            }
            entities = entityList.ToArray();
            entities = entities.OrderBy(e => Caravel.Logic.GetEntity(e).GetComponent <Cv_TransformComponent>() != null ? 1 : 2)
                       .ThenByDescending(e => Caravel.Logic.GetEntity(e).GetComponent <Cv_TransformComponent>() != null ?
                                         Caravel.Logic.GetEntity(e).GetComponent <Cv_TransformComponent>().Position.Z : 0).ToArray();
            return(result);
        }