/// <summary> /// Registers a component to its system. /// </summary> /// <param name="system">Identifier of system to register to.</param> /// <param name="id">Entity id.</param> /// <param name="component">Component to register.</param> public static void RegisterComponentToSystem( ComponentSystemId system, int id, IComponent component ) { try { Systems[system].RegisterComponent(id, component); } catch (Exception e) { throw (e); } }
/// <summary> /// Unregisters a component from its system. /// </summary> /// <param name="system">Identifier of system to register to.</param> /// <param name="id">Entity id.</param> /// <param name="component">Component to register.</param> public static void UnregisterComponentToSystem( ComponentSystemId system, int id, IComponent component ) { try { UnregisterComponents.Add( new Tuple <int, ComponentSystemId>(id, system) ); } catch (Exception e) { throw (e); } }
/// <summary> /// Gets a reference to the component with a given id. /// </summary> /// <param name="id">ComponentSystemId of component.</param> /// <returns>Component or null.</returns> public IComponent GetComponent(ComponentSystemId id) { if (Components == null) { throw (new NullReferenceException()); } foreach (IComponent component in Components) { if (component.ComponentSystem == id) { return(component); } } return(null); }