private void OnProcessorAdded(EntityProcessor processor) { processor.EntityManager = this; processor.Services = Services; processor.OnSystemAdd(); // Update processor per types and dependencies foreach (var componentTypeAndProcessors in MapComponentTypeToProcessors) { var componentType = componentTypeAndProcessors.Key; var processorList = componentTypeAndProcessors.Value; if (processor.Accept(componentType)) { componentTypeAndProcessors.Value.Add(processor); } // Add dependent component if (processor.IsDependentOnComponentType(componentType)) { if (processorList.Dependencies == null) { processorList.Dependencies = new List <EntityProcessor>(); } processorList.Dependencies.Add(processor); } } // NOTE: It is important to perform a ToList() as the TransformProcessor adds children // entities and modifies the current list of entities foreach (var entity in entities.ToList()) { CheckEntityWithNewProcessor(entity, processor); } }
private void CheckEntityWithNewProcessor(Entity entity, EntityProcessor processor) { var components = entity.Components; for (int i = 0; i < components.Count; i++) { var component = components[i]; if (processor.Accept(component.GetType().GetTypeInfo())) { processor.ProcessEntityComponent(entity, component, false); } } }