示例#1
0
    /// <summary>
    /// Processes the context.
    /// </summary>
    /// <remarks>
    /// <para>
    /// Applied during the <see cref="InputBuildState.FilterComponents"/> state.
    /// </para>
    /// </remarks>
    /// <param name="state">The current state of the input build.</param>
    /// <param name="context">The input context to process.</param>
    /// <returns>False if the input build should abort.</returns>
    public bool ProcessInput(InputBuildContext context, InputBuildState state)
    {
        if (state != InputBuildState.FilterComponents)
        {
            return(true);
        }

        if (meshes == null)
        {
            context.LogError(name + " Mesh exclusion list is null. (Invalid processor state.)"
                             , this);
            return(false);
        }

        if (meshes.Count == 0)
        {
            context.Log(name + ": Filter is inactive. No meshes configured to filter.", this);
            return(true);
        }

        List <Component> targetFilters = context.components;

        int removed = 0;

        for (int iTarget = targetFilters.Count - 1; iTarget >= 0; iTarget--)
        {
            if (!(targetFilters[iTarget] is MeshFilter))
            {
                continue;
            }

            MeshFilter filter = (MeshFilter)targetFilters[iTarget];

            if (!filter)
            {
                continue;
            }

            MatchPredicate p = new MatchPredicate(filter.sharedMesh, matchType, true);

            int iSource = meshes.FindIndex(p.Matches);

            if (iSource != -1)
            {
                targetFilters.RemoveAt(iTarget);
                removed++;
            }
        }

        if (removed > 0)
        {
            context.Log(string.Format("{0}: Filtered out {1} components.", name, removed), this);
        }
        else
        {
            context.Log(name + ": No components filtered.", this);
        }

        return(true);
    }
    /// <summary>
    /// Processes the context.
    /// </summary>
    /// <remarks>
    /// <para>
    /// Applied during the <see cref="InputBuildState.ApplyAreaModifiers"/> state.
    /// </para>
    /// </remarks>
    /// <param name="state">The current state of the input build.</param>
    /// <param name="context">The input context to process.</param>
    /// <returns>False if the input build should abort.</returns>
    public bool ProcessInput(InputBuildContext context, InputBuildState state)
    {
        if (state != InputBuildState.ApplyAreaModifiers)
        {
            return(true);
        }

        context.info.areaModifierCount++;

        if (meshes == null || areas == null || meshes.Count != areas.Count)
        {
            context.LogError("Mesh/Area size error. (Invalid processor state.)", this);
            return(false);
        }

        if (meshes.Count == 0)
        {
            context.Log("No action taken. No mesh areas defined.", this);
            return(true);
        }

        List <Component> targetFilters = context.components;
        List <byte>      targetAreas   = context.areas;

        int applied = 0;

        for (int iTarget = 0; iTarget < targetFilters.Count; iTarget++)
        {
            if (!(targetFilters[iTarget] is MeshFilter))
            {
                continue;
            }

            MeshFilter filter = (MeshFilter)targetFilters[iTarget];

            if (filter == null || targetAreas[iTarget] == org.critterai.nmgen.NMGen.NullArea)
            {
                // Never override null area.
                continue;
            }

            MatchPredicate p = new MatchPredicate(filter.sharedMesh, matchType, true);

            int iSource = meshes.FindIndex(p.Matches);

            if (iSource != -1)
            {
                targetAreas[iTarget] = areas[iSource];
                applied++;
            }
        }

        context.Log(string.Format("Applied area(s) to {0} components.", applied), this);

        return(true);
    }
示例#3
0
 internal int IndexOf(MatchPredicate predicate, object ctx)
 {
     for (int i = 0; i < length; i++)
     {
         if (predicate(data[i], ctx))
         {
             return(i);
         }
     }
     return(-1);
 }
示例#4
0
 internal int IndexOf(MatchPredicate predicate, object ctx)
 {
     return(head.IndexOf(predicate, ctx));
 }
示例#5
0
 public DelegatePredicate(MatchPredicate predicate)
 {
     this.predicate = predicate;
 }
示例#6
0
文件: BasicList.cs 项目: he0x/xRAT
 internal int IndexOf(MatchPredicate predicate, object ctx)
 {
     for (int i = 0; i < length; i++)
     {
         if (predicate(data[i], ctx)) return i;
     }
     return -1;
 }
示例#7
0
文件: BasicList.cs 项目: he0x/xRAT
 internal int IndexOf(MatchPredicate predicate, object ctx)
 {
     return head.IndexOf(predicate, ctx);
 }
示例#8
0
 public DelegatePredicate(MatchPredicate predicate)
 {
     this.predicate = predicate;
 }