コード例 #1
0
        public void OnValidate()
        {
            if (m_FrameBudgets == null)
            {
                m_FrameBudgets = new[] { 0 };
                return;
            }

            if (m_SolveOrderWeighting == default)
            {
                m_SolveOrderWeighting = GroupOrderWeights.GetDefault();
            }

            for (var i = 0; i < m_FrameBudgets.Length; i++)
            {
                if (m_FrameBudgets[i] < 0)
                {
                    m_FrameBudgets[i] = 0;
                }
            }

            var lastIndex = m_FrameBudgets.Length - 1;

            // the acquire handling stage should always have a frame of its own to work on,
            // since it can take significant time due to gameObject instantiation
            m_FrameBudgets[lastIndex] = 1;
        }
コード例 #2
0
        /// <summary>
        /// Calculate the weight that determines which of the active Groups get solved first, for a single Group.
        /// </summary>
        /// <param name="memberIndices">The member indices for the Group</param>
        /// <param name="relationCount">The number of relations in the Group</param>
        /// <param name="memberExclusivities">The global container for all group members' Exclusivity value</param>
        /// <param name="weights">The configured weights that determine how important each contribution is</param>
        /// <returns>The order weighting for the Group - higher numbers go before lower ones</returns>
        internal static float GetGroupOrderWeight(int[] memberIndices, int relationCount,
                                                  Exclusivity[] memberExclusivities, GroupOrderWeights weights)
        {
            var score = relationCount * weights.RelationWeight;

            foreach (var memberIndex in memberIndices)
            {
                switch (memberExclusivities[memberIndex])
                {
                case Exclusivity.Reserved:
                    score += weights.ReservedMemberWeight;
                    break;

                case Exclusivity.Shared:
                    score += weights.SharedMemberWeight;
                    break;
                }
            }

            return(score);
        }