예제 #1
0
        protected override IEnumerable <string> ApplyPartWorker(Pawn pawn, object cause)
        {
            CompTFTracker tracker = pawn.GetComp <CompTFTracker>();

            Color target = tracker.LoadData <Color>(this, SkinColorTarget);

            if (target.NullOrClear())
            {
                target = colorGenerator.NewRandomizedColor();
                tracker.SaveData(this, SkinColorTarget, target);
            }

            tracker.SaveData(null, "skinColor", ColorUtility.MoveTowards(pawn.story.SkinColor, target, delta));
            tracker.SaveData(null, SkinColorPower, power);
            pawn.Drawer.renderer.graphics.ResolveAllGraphics();
            PortraitsCache.SetDirty(pawn);
            yield break;
        }
        public static bool Prefix(Pawn_StoryTracker __instance, ref Color __result)
        {
            Pawn          pawn    = (Pawn)typeof(Pawn_StoryTracker).GetField("pawn", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
            CompTFTracker tracker = pawn.GetComp <CompTFTracker>();

            Color skinColor = tracker?.LoadData <Color>(null, "skinColor") ?? Color.clear;

            if (skinColor.NullOrClear())
            {
                // Allow the original method.
                return(true);
            }
            else
            {
                __result = skinColor;
                // Don't allow original to execute.
                return(false);
            }
        }
        protected override bool CheckPartWorker(Pawn pawn, object cause)
        {
            CompTFTracker tracker = pawn.GetComp <CompTFTracker>();
            Color         target  = tracker.LoadData <Color>(this, HairColorTarget);

            if (pawn.story == null)
            {
                return(false);
            }
            else if (tracker == null)
            {
                Log.Warning($"Considered setting hair color on pawn {pawn.LabelShort} who lacks a CompTFTracker.");
                return(false);
            }
            else if (power < tracker.LoadData <float>(null, HairColorPower))
            {
                return(false);
            }
            else if (!target.NullOrClear() && pawn.story.hairColor.IndistinguishableFrom(target))
            {
                return(false);
            }
            return(true);
        }