Exemple #1
0
        /// <summary>
        /// Checks the race of this pawn. If the pawn is mutated enough it's race is changed to one of the hybrids
        /// </summary>
        /// <param name="pawn">The pawn.</param>
        /// <param name="addMissingMutations">if true, any missing mutations from the highest morph influence will be added</param>
        /// <param name="displayNotifications">if set to <c>true</c> display race shift notifications.</param>
        /// <exception cref="ArgumentNullException">pawn</exception>
        /// <exception cref="System.ArgumentNullException">pawn</exception>
        public static void CheckRace([NotNull] this Pawn pawn, bool addMissingMutations = true, bool displayNotifications = true)
        {
            if (pawn == null)
            {
                throw new ArgumentNullException(nameof(pawn));
            }

            if (pawn.ShouldBeConsideredHuman())
            {
                return;
            }

            MutationTracker mutTracker = pawn.GetMutationTracker();

            var hInfluence = mutTracker.HighestInfluence;

            if (hInfluence == null)
            {
                return;
            }
            float morphInfluence          = mutTracker.GetDirectNormalizedInfluence(hInfluence);
            int   morphInfluenceCount     = mutTracker.Count();
            var   isBelowChimeraThreshold = morphInfluence < CHIMERA_THRESHOLD && morphInfluenceCount > 1;

            MorphDef setMorph = GetMorphForPawn(pawn, isBelowChimeraThreshold, hInfluence, out MorphDef curMorph);

            if (setMorph?.raceSettings?.PawnCanBecomeHybrid(pawn) == false)
            {
                return;
            }
            if (curMorph != setMorph && setMorph != null)
            {
                RaceShiftUtilities.ChangePawnToMorph(pawn, setMorph, addMissingMutations, displayNotifications);
            }
        }