示例#1
0
    /// <summary>
    ///     Checks if the interest groups have changed and perform action if necessary.
    /// </summary>
    private void CheckGroupsChanged()
    {
        if (cullArea.NumberOfSubdivisions == 0)
        {
            return;
        }

        previousActiveCells = new List <int>(activeCells);
        activeCells         = cullArea.GetActiveCells(transform.position);

        if (activeCells.Count != previousActiveCells.Count)
        {
            UpdateInterestGroups();
            return;
        }

        foreach (int groupId in activeCells)
        {
            if (!previousActiveCells.Contains(groupId))
            {
                UpdateInterestGroups();
                return;
            }
        }
    }
    /// <summary>
    ///     Checks if the previously active cells have changed.
    /// </summary>
    /// <returns>True if the previously active cells have changed and false otherwise.</returns>
    private bool HaveActiveCellsChanged()
    {
        if (cullArea.NumberOfSubdivisions == 0)
        {
            return(false);
        }

        previousActiveCells = new List <int>(activeCells);
        activeCells         = cullArea.GetActiveCells(transform.position);

        // If the player leaves the area we insert the whole area itself as an active cell.
        // This can be removed if it is sure that the player is not able to leave the area.
        while (activeCells.Count <= cullArea.NumberOfSubdivisions)
        {
            activeCells.Add(cullArea.FIRST_GROUP_ID);
        }

        if (activeCells.Count != previousActiveCells.Count)
        {
            return(true);
        }

        if (activeCells[cullArea.NumberOfSubdivisions] != previousActiveCells[cullArea.NumberOfSubdivisions])
        {
            return(true);
        }

        return(false);
    }