// After resolving a pawn's apparel graphics, we conditionally render any headgear attached to apparel // (e.g. hoods, masks, helmets) depending on the Gizmo state in CompApparelWithAttachedHeadgear static void Postfix(PawnGraphicSet __instance, Pawn ___pawn) { using (List <Apparel> .Enumerator enumerator = ___pawn.apparel.WornApparel.GetEnumerator()) { while (enumerator.MoveNext()) { ApparelGraphicRecord item; if (enumerator.Current.TryGetComp <CompApparelWithAttachedHeadgear>() is CompApparelWithAttachedHeadgear comp) { Apparel hoodApparel = (Apparel)ThingMaker.MakeThing(comp.Props.attachedHeadgearDef); ApparelGraphicRecordGetter.TryGetGraphicApparel(hoodApparel, ___pawn.story.bodyType, out ApparelGraphicRecord hoodApparelGraphicRecord); if (comp.isHatOn) { ___pawn.Drawer.renderer.graphics.apparelGraphics.Add(hoodApparelGraphicRecord); } else { ___pawn.Drawer.renderer.graphics.apparelGraphics.RemoveAll(x => x.sourceApparel == hoodApparel); } GlobalTextureAtlasManager.TryMarkPawnFrameSetDirty(___pawn); } } } }
public override void CompTickRare() { Pawn pawn = base.parent as Pawn; Map map = pawn?.Map; if (Settings.OnlyApplyToColonists && pawn.Faction?.IsPlayer == false) { return; } if (map != null && Settings.Indoors != Indoors.ShowHats && pawn.RaceProps?.Humanlike == true && !pawn.Dead) { if (this.isIndoors == null) { this.isIndoors = DetermineIsIndoors(pawn, map); PortraitsCache.SetDirty(pawn); GlobalTextureAtlasManager.TryMarkPawnFrameSetDirty(pawn); return; } bool orig = this.isIndoors.Value; this.isIndoors = this.DetermineIsIndoors(pawn, map); if (orig != this.isIndoors.Value) { PortraitsCache.SetDirty(pawn); GlobalTextureAtlasManager.TryMarkPawnFrameSetDirty(pawn); } } }
protected override IEnumerable <Toil> MakeNewToils() { // Go to hairdressing table var gotoToil = Toils_Goto.GotoThing(TableIndex, PathEndMode.InteractionCell); yield return(gotoToil); // Bring up interface yield return(new Toil() { initAction = () => { Find.WindowStack.Add(new Dialog_ChangeHairstyle(this)); }, defaultCompleteMode = ToilCompleteMode.Never }); // Change hairstyle var hairdressToil = new Toil { tickAction = () => { // Work on changing hairstyle restyleTicksDone += pawn.GetStatValue(RimWorld.StatDefOf.GeneralLaborSpeed); if (restyleTicksDone >= ticksToRestyle) { if (AnyChanges) { FilthMaker.TryMakeFilth(pawn.Position, pawn.Map, ThingDefOf.VHE_Filth_Hair, 3); } if (newHairDef != null) { pawn.story.hairDef = newHairDef; } if (newHairColour.HasValue) { pawn.story.hairColor = newHairColour.Value; } if (newBeardDef != null) { this.pawn.style.beardDef = newBeardDef; } pawn.Drawer.renderer.graphics.ResolveAllGraphics(); PortraitsCache.SetDirty(pawn); GlobalTextureAtlasManager.TryMarkPawnFrameSetDirty(pawn); pawn.jobs.EndCurrentJob(JobCondition.Succeeded); } }, defaultCompleteMode = ToilCompleteMode.Never }; hairdressToil.WithProgressBar(TableIndex, () => restyleTicksDone / ticksToRestyle, true); hairdressToil.FailOnCannotTouch(TableIndex, PathEndMode.Touch); hairdressToil.PlaySustainerOrSound(SoundDefOf.Recipe_Tailor); yield return(hairdressToil); }
public static void Notify_EquipmentChanged(this Pawn_EquipmentTracker tracker) { LongEventHandler.ExecuteWhenFinished(delegate { tracker.pawn.Drawer.renderer.graphics.SetApparelGraphicsDirty(); PortraitsCache.SetDirty(tracker.pawn); GlobalTextureAtlasManager.TryMarkPawnFrameSetDirty(tracker.pawn); }); }
static void Postfix(Pawn_DraftController __instance) { var p = __instance.pawn; if (p.IsColonist && !p.Dead && p.def.race.Humanlike) { PortraitsCache.SetDirty(p); GlobalTextureAtlasManager.TryMarkPawnFrameSetDirty(p); } }
protected override IEnumerable <Toil> MakeNewToils() { // Go to hairdressing table Toil gotoToil = Toils_Goto.GotoThing(TableIndex, PathEndMode.InteractionCell); yield return(gotoToil); // Bring up interface yield return(new Toil() { initAction = () => { Find.WindowStack.Add(new Dialog_ChangeFacepaint(this)); }, defaultCompleteMode = ToilCompleteMode.Never }); // Change hairstyle Toil hairdressToil = new Toil { tickAction = () => { // Work on changing hairstyle restyleTicksDone += pawn.GetStatValue(RimWorld.StatDefOf.GeneralLaborSpeed); if (restyleTicksDone >= ticksToRestyle) { //if (AnyChanges) ; //FilthMaker.TryMakeFilth(pawn.Position, pawn.Map, ThingDefOf.VHE_Filth_Hair, 3); if (pawn.GetComp <CompFacepaint>() is CompFacepaint facepaintComp) { facepaintComp.facepaintDefOne = this.newFacepaintDefOne; if (this.newFacepaintColorOne.HasValue) { facepaintComp.colorOne = this.newFacepaintColorOne.Value; } facepaintComp.facepaintDefTwo = this.newFacepaintDefTwo; if (this.newFacepaintColorTwo.HasValue) { facepaintComp.colorTwo = this.newFacepaintColorTwo.Value; } } GlobalTextureAtlasManager.TryMarkPawnFrameSetDirty(pawn); pawn.Drawer.renderer.graphics.ResolveAllGraphics(); PortraitsCache.SetDirty(pawn); pawn.jobs.EndCurrentJob(JobCondition.Succeeded); } }, defaultCompleteMode = ToilCompleteMode.Never }; hairdressToil.WithProgressBar(TableIndex, () => restyleTicksDone / ticksToRestyle, true); hairdressToil.FailOnCannotTouch(TableIndex, PathEndMode.Touch); hairdressToil.PlaySustainerOrSound(SoundDefOf.TinyBell); yield return(hairdressToil); }
public void ApplyToPawn(Pawn pawn, bool coloursTied) { if (pawn.GetComp <CompFacepaint>() is CompFacepaint facepaintComp) { facepaintComp.facepaintDefOne = this.facepaintDefOne; facepaintComp.colorOne = this.colourOne; facepaintComp.facepaintDefTwo = this.facepaintDefTwo; facepaintComp.colorTwo = this.FacepaintColor(coloursTied); } pawn.Drawer.renderer.graphics.ResolveAllGraphics(); PortraitsCache.SetDirty(pawn); GlobalTextureAtlasManager.TryMarkPawnFrameSetDirty(pawn); }
public override void ExposeData() { base.ExposeData(); if (ToSave == null) { ToSave = new ToSave(); } if (Scribe.mode == LoadSaveMode.Saving) { ToSave.Clear(); if (Current.Game != null) { foreach (var p in PawnsFinder.AllMaps) { if (p.IsColonist && !p.Dead && p.def.race.Humanlike) { PortraitsCache.SetDirty(p); GlobalTextureAtlasManager.TryMarkPawnFrameSetDirty(p); } } } foreach (KeyValuePair <ThingDef, HatHideEnum> kv in HatsThatHide) { switch (kv.Value) { case HatHideEnum.HidesAllHair: ToSave.hatsThatHideHair.Add(kv.Key.defName); break; case HatHideEnum.HidesHairShowBeard: ToSave.hatsToHideShowBeards.Add(kv.Key.defName); break; case HatHideEnum.HideHat: ToSave.hatsToHide.Add(kv.Key.defName); break; case HatHideEnum.OnlyDraftSH: ToSave.hatsToHideUnlessDraftedSH.Add(kv.Key.defName); break; case HatHideEnum.OnlyDraftHH: ToSave.hatsToHideUnlessDraftedHH.Add(kv.Key.defName); break; case HatHideEnum.OnlyDraftHHSB: ToSave.hatsToHideUnlessDraftedHHSB.Add(kv.Key.defName); break; default: // ShowHair, do nothing break; } } ToSave.hairToHide = new List <string>(); foreach (KeyValuePair <HairDef, bool> kv in HairToHide) { if (kv.Value) { ToSave.hairToHide.Add(kv.Key.defName); } } } Scribe_Collections.Look(ref ToSave.hatsThatHideHair, "HatsThatHide", LookMode.Value); Scribe_Collections.Look(ref ToSave.hatsToHideShowBeards, "HatsToHideShowBeards", LookMode.Value); Scribe_Collections.Look(ref ToSave.hatsToHideUnlessDraftedSH, "HatsToHideUnlessDraftedSH", LookMode.Value); Scribe_Collections.Look(ref ToSave.hatsToHideUnlessDraftedHH, "HatsToHideUnlessDraftedHH", LookMode.Value); Scribe_Collections.Look(ref ToSave.hatsToHideUnlessDraftedHHSB, "hatsToHideUnlessDraftedHHSB", LookMode.Value); Scribe_Collections.Look(ref ToSave.hatsToHide, "HatsToHide", LookMode.Value); Scribe_Collections.Look(ref ToSave.hairToHide, "HairToHide", LookMode.Value); Scribe_Values.Look <bool>(ref HideAllHats, "HideAllHats", false, false); Scribe_Values.Look <bool>(ref OnlyApplyToColonists, "OnlyApplyToColonists", false, false); Scribe_Values.Look <bool>(ref ShowHatsOnlyWhenDrafted, "ShowHatsOnlyWhenDrafted", false, false); Scribe_Values.Look <bool>(ref ShowHatsWhenDraftedIndoors, "ShowHatsWhenDraftedIndoors", false, false); Scribe_Values.Look <Indoors>(ref Indoors, "Indoors", Indoors.ShowHats, false); if (Scribe.mode != LoadSaveMode.Saving) { bool b = false; Scribe_Values.Look <bool>(ref b, "HideHatsIndoors", false, false); if (b) { Indoors = Indoors.HideHats; } } Scribe_Values.Look <bool>(ref UpdatePortrait, "UpdatePortrait", false, false); Scribe_Values.Look <bool>(ref UseDontShaveHead, "UseDontShaveHead", true, false); if (Scribe.mode == LoadSaveMode.Saving) { ToSave?.Clear(); ToSave = null; } OptionsOpen = false; }