ARKBreedingStats.Creature.ancestorGenerations C# (CSharp) Метод

ancestorGenerations() приватный Метод

Returns the number of generations to the oldest known ancestor
private ancestorGenerations ( int g ) : int
g int
Результат int
        private int ancestorGenerations(int g = 0)
        {
            // to detect loop (if a creature is falsely listed as its own ancestor)
            if (g > 99)
                return 0;

            int mgen = 0, fgen = 0;
            if (mother != null)
                mgen = mother.ancestorGenerations(g + 1) + 1;
            if (father != null)
                fgen = father.ancestorGenerations(g + 1) + 1;
            if (isBred && mgen == 0 && fgen == 0)
                return 1;
            if (mgen > fgen)
                return mgen;
            else
                return fgen;
        }

Usage Example

Пример #1
0
        /// <summary>
        /// Returns the number of generations to the oldest known ancestor
        /// </summary>
        /// <returns></returns>
        private int ancestorGenerations(int g = 0)
        {
            // to detect loop (if a creature is falsely listed as its own ancestor)
            if (g > 99)
            {
                return(0);
            }

            int mgen = 0, fgen = 0;

            if (mother != null)
            {
                mgen = mother.ancestorGenerations(g + 1) + 1;
            }
            if (father != null)
            {
                fgen = father.ancestorGenerations(g + 1) + 1;
            }
            if (isBred && mgen == 0 && fgen == 0)
            {
                return(1);
            }
            if (mgen > fgen)
            {
                return(mgen);
            }
            else
            {
                return(fgen);
            }
        }