Esempio n. 1
0
        private void ApplyEntityToSystems(IEnumerable <ISystem> systems, IEntity entity)
        {
            systems.OfType <ISetupSystem>()
            .OrderByPriority()
            .ForEachRun(x =>
            {
                var possibleSubscription = SetupSystemHandler.ProcessEntity(x, entity);
                if (possibleSubscription != null)
                {
                    _systemSubscriptions[x].Add(possibleSubscription);
                }
            });

            systems.OfType <IReactToEntitySystem>()
            .OrderByPriority()
            .ForEachRun(x =>
            {
                var subscription = ReactToEntitySystemHandler.ProcessEntity(x, entity);
                _systemSubscriptions[x].Add(subscription);
            });

            systems.Where(x => x.IsReactiveDataSystem())
            .OrderByPriority()
            .ForEachRun(x =>
            {
                var subscription = ReactToDataSystemHandler.ProcessEntityWithoutType(x, entity);
                _systemSubscriptions[x].Add(subscription);
            });
        }
        public void AddSystemsToEntity(IEntity entity, ISystemContainer container)
        {
            for (int i = 0; i < container.SetupSystems.Length; i++)
            {
                var system       = container.SetupSystems[i];
                var subscription = SetupSystemHandler.ProcessEntity(system, entity);
                if (subscription != null)
                {
                    _entitySubscribtionsOnSystems[system].Add(entity, subscription);
                }
            }

            for (int i = 0; i < container.EntityReactionSystems.Length; i++)
            {
                var system       = container.EntityReactionSystems[i];
                var subscription = EntityReactionSystemHandler.ProcessEntity(system, entity);
                if (subscription != null)
                {
                    _entitySubscribtionsOnSystems[system].Add(entity, subscription);
                }
            }

            for (int i = 0; i < container.InteractReactionSystems.Length; i++)
            {
                var system       = container.InteractReactionSystems[i];
                var subscription = InteractReactionSystemHandler.ProcessEntity(system, entity);
                if (subscription != null)
                {
                    _entitySubscribtionsOnSystems[system].Add(entity, subscription);
                }
            }
        }