/// <summary> /// Creates a component for that T type of IComponent /// Gets the manager of type T components and calls the factory to create a component /// </summary> /// <typeparam name="T">Type of IComponent to create</typeparam> /// <param name="owner">Owner entity to which the IComponent belongs</param> /// <returns>The instance of the created component</returns> public T RequestComponent<T>(IEntity owner) where T : IComponent, new() { //Create the component T c = componentFactory.CreateComponent<T>(owner); //Get the manager of type T ComponentManager manager = GetManager(typeof(T)); manager.AddComponent(c); //Check if component is drawable -> register it IVisible drawable = c as IVisible; if (drawable != null) { renderer.RegisterDrawable(drawable); } //Check if component is collidable -> register it ICollidable collidable = c as ICollidable; if (collidable != null) { collisionManager.RegisterCollidable(collidable); } return c; }