private static EntityRuleBuilder Simple(EntityRuleBuilder builder, Type[] componentTypes, MethodInfo method)
        {
            foreach (Type componentType in componentTypes)
            {
                method.MakeGenericMethod(componentType).Invoke(builder, null);
            }

            return(builder);
        }
        private static EntityRuleBuilder Either(EntityRuleBuilder builder, Type[] componentTypes, MethodInfo method)
        {
            EntityRuleBuilder.EitherBuilder eitherBuilder = null;

            foreach (Type componentType in componentTypes)
            {
                if (eitherBuilder is null)
                {
                    eitherBuilder = (EntityRuleBuilder.EitherBuilder)method.MakeGenericMethod(componentType).Invoke(builder, null);
                }
                else
                {
                    _or.MakeGenericMethod(componentType).Invoke(eitherBuilder, null);
                }
            }

            if (eitherBuilder != null)
            {
                _commit.Invoke(eitherBuilder, null);
            }

            return(builder);
        }
 /// <summary>
 /// Makes a rule to ignore <see cref="Entity"/> with at least one component of the given types.
 /// </summary>
 /// <param name="builder">The <see cref="EntityRuleBuilder"/> on which to create the rule.</param>
 /// <param name="componentTypes">The types of component.</param>
 /// <returns>The current <see cref="EntityRuleBuilder"/>.</returns>
 public static EntityRuleBuilder Without(this EntityRuleBuilder builder, params Type[] componentTypes) => Simple(builder, componentTypes, _without);
 /// <summary>
 /// Makes a rule to observe <see cref="Entity"/> when one component of the given types is removed.
 /// </summary>
 /// <param name="builder">The <see cref="EntityRuleBuilder"/> on which to create the rule.</param>
 /// <param name="componentTypes">The types of component.</param>
 /// <returns>The current <see cref="EntityRuleBuilder"/>.</returns>
 public static EntityRuleBuilder WhenRemovedEither(this EntityRuleBuilder builder, params Type[] componentTypes) => Either(builder, componentTypes, _whenRemovedEither);
 /// <summary>
 /// Makes a rule to obsverve <see cref="Entity"/> without at least one component of the given types.
 /// </summary>
 /// <param name="builder">The <see cref="EntityRuleBuilder"/> on which to create the rule.</param>
 /// <param name="componentTypes">The types of component.</param>
 /// <returns>The current <see cref="EntityRuleBuilder"/>.</returns>
 public static EntityRuleBuilder WithoutEither(this EntityRuleBuilder builder, params Type[] componentTypes) => Either(builder, componentTypes, _withoutEither);
 /// <summary>
 /// Makes a rule to obsverve <see cref="Entity"/> when all component of the given types are removed.
 /// </summary>
 /// <param name="builder">The <see cref="EntityRuleBuilder"/> on which to create the rule.</param>
 /// <param name="componentTypes">The types of component.</param>
 /// <returns>The current <see cref="EntityRuleBuilder"/>.</returns>
 public static EntityRuleBuilder WhenRemoved(this EntityRuleBuilder builder, params Type[] componentTypes) => Simple(builder, componentTypes, _whenRemoved);
Exemplo n.º 7
0
 internal EitherBuilder(EntityRuleBuilder builder, EitherType type)
 {
     _builder = builder;
     _type    = type;
 }