private void OnProcessorRemoved(EntityProcessor processor) { // Remove the procsesor from any list foreach (var componentTypeAndProcessors in MapComponentTypeToProcessors) { var processorList = componentTypeAndProcessors.Value; processorList.Remove(processor); if (processorList.Dependencies != null) { processorList.Dependencies.Remove(processor); } } processor.RemoveAllEntities(); processor.OnSystemRemove(); processor.Services = null; processor.EntityManager = null; }
// // Called when a new Entity Processor has been added to the Entity Manager. // 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 is 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); } }