Example #1
0
        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);
            }
        }