/// <summary> /// Returns an instance of requested entity. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="pUName"></param> /// <param name="pTexture"></param> /// <param name="pAIComponentManager"></param> /// <returns></returns> public IEntity RequestInstance <T>(String pUName, Texture2D pTexture) where T : IEntity, new() { // request a new instance of an entity IEntity entity = new T(); // if entity has implements ICollisionListenr add the listener if (entity is ICollisionListener) { _collisionManager.AddListener(((ICollisionListener)entity).OnNewCollision); } // give the entity a mind entity.SetAIComponentManager(_AIComponentManager); // set the texture for the entity entity.SetTexture(pTexture); // initialise the entity entity.Initialise(); // Generate the entities UID and UName GenerateUID(entity, pUName); // Add entity to the entity list _entityList.Add(entity); // return the requested entity return(entity); }