Beispiel #1
0
        public SubscriptionToken Setup(IReactToGroupSystem system)
        {
            var hasEntityPredicate = system.TargetGroup.TargettedEntities != null;
            var groupAccessor      = PoolManager.CreateGroupAccessor(system.TargetGroup);
            var subscription       = system.ReactToGroup(groupAccessor)
                                     .Subscribe(accessor =>
            {
                var entities    = accessor.Entities;
                var entityCount = entities.Count() - 1;
                for (var i = entityCount; i >= 0; i--)
                {
                    if (hasEntityPredicate)
                    {
                        if (system.TargetGroup.TargettedEntities(entities.ElementAt(i)))
                        {
                            system.Execute(entities.ElementAt(i));
                        }
                        return;
                    }

                    system.Execute(entities.ElementAt(i));
                }
            });

            return(new SubscriptionToken(null, subscription));
        }
        public SubscriptionToken Setup(IReactToGroupSystem system)
        {
            var hasEntityPredicate = system.TargetGroup is IHasPredicate;
            var groupAccessor      = PoolManager.CreateGroupAccessor(system.TargetGroup);
            var subscription       = system.ReactToGroup(groupAccessor)
                                     .Subscribe(accessor =>
            {
                var entities    = accessor.Entities.ToList();
                var entityCount = entities.Count - 1;
                for (var i = entityCount; i >= 0; i--)
                {
                    if (hasEntityPredicate)
                    {
                        var groupPredicate = system.TargetGroup as IHasPredicate;
                        if (groupPredicate.CanProcessEntity(entities[i]))
                        {
                            system.Execute(entities[i]);
                        }
                        continue;
                    }

                    system.Execute(entities[i]);
                }
            });

            return(new SubscriptionToken(null, subscription));
        }
Beispiel #3
0
        public SubscriptionToken Setup(IReactToGroupSystem system)
        {
            var hasEntityPredicate = system.TargetGroup.TargettedEntities != null;
            var groupAccessor      = PoolManager.CreateGroupAccessor(system.TargetGroup);
            var subscription       = system.ReactToGroup(groupAccessor)
                                     .Subscribe(accessor =>
            {
                var entities = accessor.Entities.ToArray();
                entities.ForEachRun(entity =>
                {
                    if (hasEntityPredicate)
                    {
                        if (system.TargetGroup.TargettedEntities(entity))
                        {
                            system.Execute(entity);
                        }
                        return;
                    }

                    system.Execute(entity);
                });
            });

            return(new SubscriptionToken(null, subscription));
        }