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); }
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); }
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); }