Beispiel #1
0
        bool UpdateHairColor([NotNull] MutationTracker tracker)
        {
            var highestInfluence = Pawn.GetHighestInfluence();
            var curMorph         = Pawn.def.GetMorphOfRace();

            if (highestInfluence == null || highestInfluence == curMorph)
            {
                return(false);                                                          //if there is not influence or if the highest influence is
            }
            //that of their current race do nothing
            if (GComp == null || InitialGraphics == null || Pawn.story == null)
            {
                return(false);
            }

            float lerpVal    = tracker.GetDirectNormalizedInfluence(highestInfluence);
            var   baseColor  = curMorph?.GetHairColorOverride(tracker.Pawn) ?? InitialGraphics.HairColor;
            var   morphColor = highestInfluence.GetHairColorOverride(tracker.Pawn) ?? InitialGraphics.HairColor;

            if (baseColor == morphColor)
            {
                return(false);                                    //if they're the same color don't  do anything
            }
            var col = Color.Lerp(baseColor, morphColor, lerpVal); //blend the 2 by the normalized colors

            Pawn.story.hairColor = GComp.ColorChannels["hair"].first = col;

            return(true);
        }
        bool UpdateSkinColor([NotNull] MutationTracker tracker, bool force = false)
        {
            if (GComp == null || InitialGraphics == null)
            {
                return(false);
            }

            var colorationAspect = tracker.Pawn.GetAspectTracker()?.GetAspect <Aspects.ColorationAspect>();

            if (colorationAspect != null && colorationAspect.IsFullOverride)
            {
                var color = colorationAspect.ColorSet.skinColor;
                if (color.HasValue)
                {
                    GComp.skinColor = color.Value;
                    return(true);
                }
            }

            var highestInfluence = Pawn.GetHighestInfluence();
            var curMorph         = Pawn.def.GetMorphOfRace();

            if (highestInfluence == null || (!force && highestInfluence == curMorph))
            {
                if (GComp.skinColor == InitialGraphics.SkinColor)
                {
                    return(false); // If there is not influence or if the highest influence is that of their current race do nothing.
                }
                else
                {
                    GComp.skinColor = InitialGraphics.SkinColor;
                    return(true);
                }
            }


            float lerpVal    = tracker.GetDirectNormalizedInfluence(highestInfluence);
            var   baseColor  = curMorph?.GetSkinColorOverride(tracker.Pawn) ?? InitialGraphics.SkinColor;
            var   morphColor = highestInfluence.GetSkinColorOverride(tracker.Pawn) ?? InitialGraphics.SkinColor;

            if (!force && baseColor == morphColor)
            {
                return(false); // If they're the same color don't do anything.
            }

            var col = Color.Lerp(baseColor, morphColor, Mathf.Sqrt(lerpVal)); // Blend the 2 by the normalized colors.

            GComp.skinColor = GComp.ColorChannels["skin"].first = col;

            return(true);
        }