/// <summary> /// Searches for a component and returns it /// </summary> /// <typeparam name="T">Type of the component to search</typeparam> /// <returns>Instance of the component to search</returns> public T GetComponent <T>() where T : IComponent { IComponentMaster componentMaster = ServiceLocator.Instance.GetService <IComponentMaster>(); T c = componentMaster.GetComponent <T>(UID); return(c); }
/// <summary> /// Adds a component to the entity /// </summary> /// <typeparam name="T">Type of the component to be added to the entity</typeparam> /// <returns>returns the component created in the factory</returns> public T AddComponent <T>() where T : IComponent, new() { IComponentMaster componentMaster = ServiceLocator.Instance.GetService <IComponentMaster>(); T c = componentMaster.RequestComponent <T>(this); return(c); }
/// <summary> /// Removes a component from the entity and deletes it /// </summary> /// <param name="component"></param> public void RemoveComponent(IComponent component) { IComponentMaster componentMaster = ServiceLocator.Instance.GetService <IComponentMaster>(); componentMaster.RemoveComponent(component); component = null; }
private Game1() { graphics = new GraphicsDeviceManager(this); graphics.IsFullScreen = isFullScreen; if (isFullScreen) { Window.IsBorderless = true; Window.Position = new Point(0, 0); } mouseInput = new MouseInput(); Content.RootDirectory = "Content"; //Initialize all the services services = ServiceLocator.Instance; entityManager = services.StartService <EntityManager>(); collisionManager = services.StartService <CollisionManager>(); renderer = services.StartService <Renderer>(); componentMaster = services.StartService <ComponentMaster>(); services.StartService <SceneManager>(); services.StartService <ResourceManager>(); }
public void Initialize() { _sceneManager = ServiceLocator.Instance.GetService <ISceneManager>(); _componentManager = ServiceLocator.Instance.GetService <IComponentMaster>(); }