Ejemplo n.º 1
0
        // todo: вынести создание в фабрику
        public SystemReactor(ISystemExecutor systemExecutor, HashSet <Type> targetTypes)
        {
            _systemExecutor = systemExecutor;
            TargetTypesSet  = targetTypes;
            TargetTypesList = targetTypes.ToList();

            _componentIndex = new ComponentIndex(targetTypes.ToList());
            _componentIndex.Build();

            _inConnectionIndex  = new ConnectionIndex(targetTypes.ToList());
            _outConnectionIndex = new ConnectionIndex(targetTypes.ToList());

            var systems = _systemExecutor.Systems
                          .Where(x => x.TargetGroup.TargettedComponents.Any() && x.TargetGroup.TargettedComponents.All(targetTypes.Contains))
                          .ToList();

            GroupAccessors = _systemExecutor.PoolManager.PoolAccessors
                             .Where(x => new HashSet <Type>(x.AccessorToken.ComponentTypes).IsSubsetOf(targetTypes))
                             .ToArray();

            SetupSystems            = systems.OfType <ISetupSystem>().OrderByPriority().ToArray();
            EntityReactionSystems   = systems.OfType <IEntityReactionSystem>().OrderByPriority().ToArray();
            GroupReactionSystems    = systems.OfType <IGroupReactionSystem>().OrderByPriority().ToArray();
            InteractReactionSystems = systems.OfType <IInteractReactionSystem>().OrderByPriority().ToArray();
            TeardownSystems         = systems.OfType <ITeardownSystem>().OrderByPriority().ToArray();

            HasGroupOrSystems = systems.Count > 0 || GroupAccessors.Length > 0;
        }
Ejemplo n.º 2
0
 public ConnectionIndex(IEnumerable <Type> targetTypes)
 {
     _index = new ComponentIndex(targetTypes.ToList());
     _index.Build();
     _connections = new ReactorConnection[0];
 }