Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }