private T[] getComponents <T>(Constant.enumComponent componentTypeId)
        {
            List <T> componentsList = new List <T>();

            //foreach gameobject within m_ObjectList which has a component in m_components whose componentTypeId is found in componentTypeIdArray
            foreach (GameObject gameObj in m_GameObjectList.Where(obj => obj.Value.m_Components.Any(com => com.m_ComponentType.m_ComponentTypeID == componentTypeId)).Select(obj => obj.Value))
            {
                componentsList.Add(gameObj.getComponent <T>(componentTypeId));
            }
            return(componentsList.ToArray());
        }
Exemple #2
0
        public static ComponentType Instance(Constant.enumComponent iD)
        {
            if (m_InstanceList == null)
            {
                m_InstanceList = new List <ComponentType>();
            }
            if (!m_InstanceList.Any(x => x.m_ComponentTypeID == iD))
            {
                m_InstanceList.Add(new ComponentType(iD));
            }

            return(m_InstanceList.FirstOrDefault(x => x.m_ComponentTypeID == iD));
        }
Exemple #3
0
 protected ComponentType(Constant.enumComponent iD)
 {
     m_ComponentTypeID = iD;
 }
Exemple #4
0
 public T getComponent <T>(Constant.enumComponent componentID)
 {
     return((T)m_Components.Where(x => x.m_ComponentType.m_ComponentTypeID == componentID).FirstOrDefault());
 }
 private IGameObject[] getObjectWithComponent(Constant.enumComponent componentTypeID)
 {
     return(m_GameObjectList.Where(obj => obj.Value.m_Components.Any(com => com.m_ComponentType.m_ComponentTypeID == componentTypeID)).Select(obj => obj.Value).ToArray());
 }