private Color getOriginalColor(PawnColorSlot slot) { var initialGraphicsComp = targetPawn.GetComp <InitialGraphicsComp>(); switch (slot) { case PawnColorSlot.SkinFirst: return(initialGraphicsComp != null ? initialGraphicsComp.SkinColor : targetPawn.Drawer.renderer.graphics.nakedGraphic.Color); break; case PawnColorSlot.SkinSecond: return(initialGraphicsComp != null ? initialGraphicsComp.SkinColorSecond : targetPawn.Drawer.renderer.graphics.nakedGraphic.ColorTwo); break; case PawnColorSlot.HairFirst: return(initialGraphicsComp != null ? initialGraphicsComp.HairColor : targetPawn.story.hairColor); break; case PawnColorSlot.HairSecond: return(initialGraphicsComp != null ? initialGraphicsComp.HairColorSecond : Color.white); break; } return(Color.white); }
/// <summary> /// Generate a color using base Rand generator and the slot-appropriate color generator /// </summary> /// <param name="colorSlot">Color slot</param> /// <returns>Generated color, or null if base color should be used</returns> private Color?TryGenerateColorationAspectColor(PawnColorSlot colorSlot) { var seed = Find.TickManager.TicksAbs; ColorGenerator colorGen = TryGetColorationAspectColorGenerator(colorSlot); if (colorGen != null) { try { Rand.PushState((seed + (int)colorSlot) ^ 5224); //offet to generate different colors return(colorGen.NewRandomizedColor()); } finally { Rand.PopState(); } } return(null); }
private ColorGenerator TryGetColorationAspectColorGenerator(PawnColorSlot colorSlot) { if (this.def == ColorationAspectDefOfs.ColorationNatural) { switch (colorSlot) { case PawnColorSlot.SkinFirst: return(NaturalColors); case PawnColorSlot.SkinSecond: return(NaturalColors); case PawnColorSlot.HairFirst: case PawnColorSlot.HairSecond: default: return(null); } } else if (this.def == ColorationAspectDefOfs.ColorationAlbinism) { switch (colorSlot) { case PawnColorSlot.SkinFirst: return(albinismFirst); case PawnColorSlot.SkinSecond: return(albinismSecond); case PawnColorSlot.HairFirst: return(albinismFirst); case PawnColorSlot.HairSecond: default: return(null); } } else if (this.def == ColorationAspectDefOfs.ColorationMelanism) { switch (colorSlot) { case PawnColorSlot.SkinFirst: return(melanismFirst); case PawnColorSlot.SkinSecond: return(melanismSecond); case PawnColorSlot.HairFirst: return(melanismFirst); case PawnColorSlot.HairSecond: default: return(null); } } else if (this.def == ColorationAspectDefOfs.ColorationUnnatural) { switch (colorSlot) { case PawnColorSlot.SkinFirst: return(UnnaturalColors); case PawnColorSlot.SkinSecond: return(UnnaturalColors); case PawnColorSlot.HairFirst: return(UnnaturalColors); case PawnColorSlot.HairSecond: return(UnnaturalColors); default: return(null); } } else if (this.def == ColorationAspectDefOfs.ColorationPlayerPicked) { switch (colorSlot) { case PawnColorSlot.SkinFirst: if (ColorSet != null && ColorSet.skinColor.HasValue) { return new ColorGenerator_Single() { color = ColorSet.skinColor.Value } } ; else { return(null); } case PawnColorSlot.SkinSecond: if (ColorSet != null && ColorSet.skinColorTwo.HasValue) { return new ColorGenerator_Single() { color = ColorSet.skinColorTwo.Value } } ; else { return(null); } case PawnColorSlot.HairFirst: if (ColorSet != null && ColorSet.hairColor.HasValue) { return new ColorGenerator_Single() { color = ColorSet.hairColor.Value } } ; else { return(null); } case PawnColorSlot.HairSecond: if (ColorSet != null && ColorSet.hairColorTwo.HasValue) { return new ColorGenerator_Single() { color = ColorSet.hairColorTwo.Value } } ; else { return(null); } default: return(null); } } else { return(null); } }