示例#1
0
        public T AddComponent <T>() where T : Component
        {
            int       component_type_id = ComponentTypeRegistry.ComponentType2ID(typeof(T));
            Component component         = AddComponent(component_type_id);

            return(component as T);
        }
示例#2
0
        public Component GetComponent(System.Type type)
        {
            // PositionComponent cmp = object.GetComponent(typeof(PositionComponent)) as PositionComponent;
            int       component_type_id = ComponentTypeRegistry.ComponentType2ID(type);
            Component component;

            m_components.TryGetValue(component_type_id, out component);
            return(component);
        }
示例#3
0
        public T GetComponent <T>() where T : Component
        {
            // PositionComponent cmp = object.GetComponent<PositionComponent>();
            int       component_type_id = ComponentTypeRegistry.ComponentType2ID(typeof(T));
            Component component;

            if (!m_components.TryGetValue(component_type_id, out component))
            {
                return(null);
            }
            return(component as T);
        }