public static void Postfix(Apparel apparel) { if (apparel.Wearer != null) { apparel.BroadcastCompSignal(CompHediffApparel.AddHediffsToPawnSignal); } }
public static void Postfix(Apparel apparel) { if (apparel.Wearer == null) { apparel.BroadcastCompSignal(CompHediffApparel.RemoveHediffsFromPawnSignal); } }
public static void Prefix(Pawn_ApparelTracker __instance, Apparel apparel) { if (__instance.pawn is Pawn pawn) { apparel.BroadcastCompSignal(CompHediffApparel.RemoveHediffsFromPawnSignal); if (apparel.def.GetModExtensionFast <ApparelRestrictionDefExtension>() is ApparelRestrictionDefExtension ext) { if (!ext.BodytypeDefs.NullOrEmpty() && ext.forcedBodytype) { OriginalBodyTracker tracker = Find.World.GetComponent <OriginalBodyTracker>(); if (tracker.ModifiedBody(pawn, out BodyTypeDef original)) { HarmonyPatches.ChangeBodyType(pawn, original); tracker.originalBody.Remove(pawn); } } } } }
public static void Prefix(Pawn_ApparelTracker __instance, Apparel apparel) { if (apparel.Wearer is Pawn pawn) { apparel.BroadcastCompSignal(CompHediffApparel.AddHediffsToPawnSignal); if (apparel.def.GetModExtensionFast <ApparelRestrictionDefExtension>() is ApparelRestrictionDefExtension ext && pawn.story != null) { if (!ext.BodytypeDefs.NullOrEmpty() && ext.forcedBodytype && !ext.BodytypeDefs.Contains(pawn.story.bodyType)) { OriginalBodyTracker tracker = Find.World.GetComponent <OriginalBodyTracker>(); if (!tracker.ModifiedBody(pawn, out BodyTypeDef original)) { tracker.originalBody.SetOrAdd(apparel.Wearer, apparel.Wearer.story.bodyType); HarmonyPatches.ChangeBodyType(pawn, ext.BodytypeDefs.RandomElement()); } } } } }
public static void Postfix(ref Apparel apparel, BodyTypeDef bodyType, ref ApparelGraphicRecord rec) { /* * bool Pauldron = apparel.TryGetCompFast<CompPauldronDrawer>() != null; * if (Pauldron) * { * // Log.Message("Updating pad graphics for "+apparel.LabelShortCap); * for (int i = 0; i < apparel.GetComps<CompPauldronDrawer>().Count(); i++) * { * // Log.Message("Pauldron drawer "+(i+1)); * CompPauldronDrawer comp = apparel.GetComps<CompPauldronDrawer>().ElementAt(i); * if (!comp.activeEntries.NullOrEmpty()) * { * for (int i2 = 0; i2 < comp.activeEntries.Count; i2++) * { * // Log.Message("Entry drawer " + (i2 + 1)); * comp.activeEntries[i2].UpdatePadGraphic(); * } * } * } * } */ string mskVariant = ""; if (apparel is ApparelComposite composite) { if (!composite.AltGraphics.NullOrEmpty() && composite.ActiveAltGraphic != null) { rec.graphic = composite.ActiveAltGraphic.GetGraphic(rec.graphic, true); Graphic graphic = GraphicDatabase.Get <Graphic_Multi>(composite.WornGraphicPath, apparel.def.apparel.useWornGraphicMask ? ShaderDatabase.CutoutComplex : ShaderDatabase.Cutout, apparel.def.graphicData.drawSize, composite.DrawColor, composite.DrawColorTwo); if (!composite.ActiveAltGraphic.maskKey.NullOrEmpty()) { mskVariant = "_" + composite.ActiveAltGraphic.maskKey; } rec = new ApparelGraphicRecord(graphic, apparel); } } CompColorableTwo compColorable = apparel.TryGetCompFast <CompColorableTwo>(); if (compColorable != null) { // Log.Message("CompColorableTwo "+ apparel); string comptype = compColorable.GetType().Name; string msg = string.Empty; string mskFaction = string.Empty; CompColorableTwoFaction factionColors = compColorable as CompColorableTwoFaction; Color colorOne = compColorable.Color; Color colorTwo = compColorable.ColorTwo; if (factionColors != null) { if (apparel.Wearer.Faction != null) { if (apparel.Wearer.Faction != Faction.OfPlayer) { factionColors.FactionDef = apparel.Wearer.Faction?.def; msg += " entry for Non Player Pawn using FactionDef " + factionColors.FactionDef; } else { if (factionColors.FactionDef != null) { msg += " entry for Player Pawn using FactionDef " + factionColors.FactionDef; } else { /* * CompPauldronDrawer pauldrons = apparel.TryGetCompFast<CompPauldronDrawer>(); * if (pauldrons != null) * { * for (int i = 0; i < pauldrons.activeEntries.Count; i++) * { * ShoulderPadEntry entry = pauldrons.activeEntries[i]; * if (entry.faction != null && entry.UseFactionTextures || entry.UseFactionColors) * { * factionColors.FactionDef = entry.faction; * msg += " entry for Player Pawn using FactionDef " + factionColors.FactionDef; * break; * } * * } * } * else * { * // Log.Message("CompFactionColorableTwo Player Pawn no CompPauldronDrawer"); * } */ } } } if (factionColors.Active) { // Log.Message("factionColors.Active"); colorOne = factionColors.Color; apparel.SetColorOne(colorOne); } if (factionColors.ActiveTwo) { // Log.Message("factionColors.ActiveTwo"); colorTwo = factionColors.ColorTwo; apparel.SetColorTwo(colorTwo); } if (factionColors.Extension != null) { // Log.Message("factionColors.Extension != null"); if (factionColors.ActiveTwo || factionColors.Active) { if (!factionColors.Extension.factionMaskTag.NullOrEmpty()) { // Log.Message("factionColors.factionMaskTag"); mskFaction = "_" + factionColors.Extension.factionMaskTag; // Log.Message("factionMaskTag: "+msk); } } } // msg if (factionColors.ActiveFaction) { comptype += "FactionActive: " + factionColors.FactionActive + ", FactionActiveTwo: " + factionColors.FactionActiveTwo; } else { comptype += "Active: " + factionColors.Active + ", ActiveTwo: " + factionColors.ActiveTwo; } } else { comptype += "Active: " + compColorable.Active + ", ActiveTwo: " + compColorable.ActiveTwo; } // Log.Message(comptype + msg + " present on " + apparel.Wearer +"'s "+ apparel + " colorOne: " + colorOne + ", colorTwo: " + colorTwo); // Log.Message("New graphic for "+rec.sourceApparel.LabelCap+" worn by "+rec.sourceApparel.Wearer.NameShortColored+ " colorOne: "+colorOne+", colorTwo"+ colorTwo); if (rec.graphic != null) { Graphic newgraphic = rec.graphic.GetColoredVersion(rec.graphic.Shader, colorOne, colorTwo); bool replaced = false; if (!apparel.def.apparel.wornGraphicPath.NullOrEmpty()) { Graphic replace = AdeptusApparelUtility.ApplyMask(newgraphic, apparel, colorOne, colorTwo, mskVariant, mskFaction); replaced = replace != null; if (replaced) { newgraphic = replace; rec = new ApparelGraphicRecord(newgraphic, apparel); } } if (!rec.graphic.path.NullOrEmpty()) { Texture texture = ContentFinder <Texture2D> .Get(rec.graphic.path + mskFaction, false); if (texture != null) { newgraphic.MatSingle.SetTexture(ShaderPropertyIDs.MaskTex, texture); } newgraphic.MatEast.SetColor(ShaderPropertyIDs.ColorTwo, colorTwo); } } // Log.Message(comptype + msg + " present on " + apparel.Wearer +"'s "+ apparel + " colorOne: " + colorOne + ", colorTwo: " + colorTwo); } if (!apparel.def.apparel.wornGraphicPath.NullOrEmpty()) { if (apparel.def.GetModExtensionFast <ApparelRestrictionDefExtension>() is ApparelRestrictionDefExtension apparelExt) { if (!apparelExt.raceSpecifics.NullOrEmpty()) { foreach (var item in apparelExt.raceSpecifics) { ThingDef RaceDef = DefDatabase <ThingDef> .GetNamedSilentFail(item.raceDef); if (RaceDef == null) { continue; } if (RaceDef == apparel.Wearer.def) { if (!item.texPath.NullOrEmpty()) { string path; if (apparel.def.apparel.LastLayer == ApparelLayerDefOf.Overhead || PawnRenderer.RenderAsPack(apparel) || apparel.def.apparel.wornGraphicPath == BaseContent.PlaceholderImagePath) { path = apparel.def.apparel.wornGraphicPath + "_" + item.texPath; } else { path = apparel.def.apparel.wornGraphicPath + "_" + item.texPath + "_" + bodyType.defName; } Graphic graphic = GraphicDatabase.Get <Graphic_Multi>(path, apparel.def.apparel.useWornGraphicMask ? ShaderDatabase.CutoutComplex : ShaderDatabase.Cutout, apparel.def.graphicData.drawSize, rec.graphic.color, rec.graphic.colorTwo); rec = new ApparelGraphicRecord(graphic, apparel); } break; } } } } } /* * for (int i = 0; i < apparel.AllComps.Count; i++) * { * CompPauldronDrawer drawer = apparel.AllComps[i] as CompPauldronDrawer; * if (drawer != null) * { * drawer. * } * * } */ apparel.BroadcastCompSignal(CompPauldronDrawer.UpdateString); }