public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn pawn) { bool isAlien = AlienRaceUtil.IsAlien(pawn); List <FloatMenuOption> list = new List <FloatMenuOption>(); if (pawn.apparel.WornApparel.Count > 0) { list.Add(new FloatMenuOption( "ChangeDresser.ChangeApparelColors".Translate(), delegate { Job job = new Job(this.changeApparelColorJobDef, this); pawn.jobs.TryTakeOrderedJob(job); })); } if (!isAlien || AlienRaceUtil.HasHair(pawn)) { list.Add(new FloatMenuOption( "ChangeDresser.ChangeHair".Translate(), delegate { Job job = new Job(this.changeHairStyleJobDef, this); pawn.jobs.TryTakeOrderedJob(job); })); } if (Settings.ShowBodyChange) { list.Add(new FloatMenuOption( "ChangeDresser.ChangeBody".Translate(), delegate { Job job = new Job(this.changeBodyJobDef, this); pawn.jobs.TryTakeOrderedJob(job); })); if (isAlien) { list.Add(new FloatMenuOption( "ChangeDresser.ChangeAlienBodyColor".Translate(), delegate { Job job = new Job(this.changeBodyAlienColor, this); pawn.jobs.TryTakeOrderedJob(job); })); } } return(list); }
static void Postfix(Pawn __instance, ref IEnumerable <Gizmo> __result) { List <Gizmo> l = new List <Gizmo>(); if ((__instance.IsPrisoner || (Settings.ShowDresserButtonForPawns && __instance.Faction == Faction.OfPlayer && __instance.def.race.Humanlike)) && WorldComp.HasDressers()) { bool isAlien = AlienRaceUtil.IsAlien(__instance); l.Add(new Command_Action { icon = WidgetUtil.yesDressFromTexture, defaultLabel = "ChangeDresser.UseDresser".Translate(), activateSound = SoundDef.Named("Click"), action = delegate { List <FloatMenuOption> options = new List <FloatMenuOption>(6) { new FloatMenuOption("ChangeDresser.Wearing".Translate(), delegate() { Find.WindowStack.Add(new StorageUI(__instance)); }), new FloatMenuOption("ChangeDresser.ChangeApparelColors".Translate(), delegate() { Find.WindowStack.Add(new DresserUI(DresserDtoFactory.Create(__instance, null, CurrentEditorEnum.ChangeDresserApparelColor))); }) }; if (Settings.IncludeColorByLayer) { options.Add(new FloatMenuOption("ChangeDresser.ChangeApparelColorsByLayer".Translate(), delegate() { Find.WindowStack.Add(new DresserUI(DresserDtoFactory.Create(__instance, null, CurrentEditorEnum.ChangeDresserApparelLayerColor))); })); } if (!isAlien || AlienRaceUtil.HasHair(__instance)) { options.Add(new FloatMenuOption("ChangeDresser.ChangeHair".Translate(), delegate() { Find.WindowStack.Add(new DresserUI(DresserDtoFactory.Create(__instance, null, CurrentEditorEnum.ChangeDresserHair))); })); } if (Settings.ShowBodyChange) { options.Add(new FloatMenuOption("ChangeDresser.ChangeBody".Translate(), delegate() { Find.WindowStack.Add(new DresserUI(DresserDtoFactory.Create(__instance, null, CurrentEditorEnum.ChangeDresserBody))); })); if (isAlien) { options.Add(new FloatMenuOption("ChangeDresser.ChangeAlienBodyColor".Translate(), delegate() { Find.WindowStack.Add(new DresserUI(DresserDtoFactory.Create(__instance, null, CurrentEditorEnum.ChangeDresserAlienSkinColor))); })); } } Find.WindowStack.Add(new FloatMenu(options)); } }); l.AddRange(__result); } if (!__instance.Drafted && WorldComp.HasDressers()) { #if DEBUG ++i; if (i == WAIT) { Log.Warning("DraftController.Postfix: Pawn is Drafted"); } #endif if (WorldComp.PawnOutfits.TryGetValue(__instance, out PawnOutfitTracker outfits)) { if (l.Count == 0) { l.AddRange(__result); } #if DEBUG if (i == WAIT) { Log.Warning("DraftController.Postfix: Sets found! Pre Gizmo Count: " + l.Count); } #endif foreach (IDresserOutfit o in outfits.CivilianOutfits) { if (o == null || !o.IsValid()) { continue; } #if DEBUG && DRESSER_OUTFIT string msg = "Patch_Pawn_GetGizmos Outfit: " + o.Label; Log.ErrorOnce(msg, msg.GetHashCode()); #endif Command_Action a = new Command_Action(); ThingDef icon = o.Icon; if (icon != null) { a.icon = HarmonyPatches.GetIcon(icon); } else { a.icon = WidgetUtil.noneTexture; } StringBuilder sb = new StringBuilder(); if (!o.IsBeingWorn) { sb.Append("ChangeDresser.ChangeTo".Translate()); a.defaultDesc = "ChangeDresser.ChangeToDesc".Translate(); } else { sb.Append("ChangeDresser.Wearing".Translate()); a.defaultDesc = "ChangeDresser.WearingDesc".Translate(); } sb.Append(" "); sb.Append(o.Label); a.defaultLabel = sb.ToString(); a.activateSound = SoundDef.Named("Click"); a.action = delegate { #if DRESSER_OUTFIT Log.Warning("Patch_Pawn_GetGizmos click for " + o.Label); #endif outfits.ChangeTo(o); //HarmonyPatches.SwapApparel(pawn, o); //outfits.ColorApparel(__instance); }; l.Add(a); } #if DEBUG if (i == WAIT) { Log.Warning("Post Gizmo Count: " + l.Count); } #endif } } #if DEBUG else { if (i == WAIT) { Log.Warning("Pawn is not Drafted, could gizmo"); } } #endif #if DEBUG if (i == WAIT) { i = 0; } #endif if (l.Count > 0) { __result = l; } }