// Verse.PawnGraphicSet public static bool Vamp_ResolveApparelGraphics(PawnGraphicSet __instance) { if (__instance.pawn.VampComp() is CompVampire v && v.CurrentForm != null) { __instance.ClearCache(); __instance.apparelGraphics.Clear(); return(false); } return(true); }
public void ResolveHideGraphic() { if (Props.hideGraphic != null && ((Pawn)parent).Drawer?.renderer?.graphics != null) { PawnGraphicSet pawnGraphicSet = ((Pawn)parent).Drawer?.renderer?.graphics; pawnGraphicSet = ((Pawn)parent).Drawer?.renderer?.graphics; pawnGraphicSet.ClearCache(); pawnGraphicSet.nakedGraphic = Props.hideGraphic.Graphic; } }
public void ResolveCycledGraphic() { if (Props.cycledGraphic != null) { Pawn_DrawTracker pawnDrawTracker = lumberer.Drawer; if (pawnDrawTracker != null) { PawnRenderer pawnRenderer = pawnDrawTracker.renderer; if (pawnRenderer != null) { PawnGraphicSet pawnGraphicSet = pawnRenderer.graphics; if (pawnGraphicSet != null) { pawnGraphicSet.ClearCache(); pawnGraphicSet.nakedGraphic = Props.cycledGraphic.Graphic; } } } } }
public void ResolveBaseGraphic() { if (Props.cycledGraphic != null) { Pawn_DrawTracker pawnDrawTracker = lumberer.Drawer; if (pawnDrawTracker != null) { PawnRenderer pawnRenderer = pawnDrawTracker.renderer; if (pawnRenderer != null) { PawnGraphicSet pawnGraphicSet = pawnRenderer.graphics; if (pawnGraphicSet != null) { pawnGraphicSet.ClearCache(); //Duplicated code from -> Verse.PawnGrapic -> ResolveAllGraphics PawnKindLifeStage curKindLifeStage = lumberer.ageTracker.CurKindLifeStage; if (lumberer.gender != Gender.Female || curKindLifeStage.femaleGraphicData == null) { pawnGraphicSet.nakedGraphic = curKindLifeStage.bodyGraphicData.Graphic; } else { pawnGraphicSet.nakedGraphic = curKindLifeStage.femaleGraphicData.Graphic; } pawnGraphicSet.rottingGraphic = pawnGraphicSet.nakedGraphic.GetColoredVersion(ShaderDatabase.CutoutSkin, PawnGraphicSet.RottingColor, PawnGraphicSet.RottingColor); if (lumberer.RaceProps.packAnimal) { pawnGraphicSet.packGraphic = GraphicDatabase.Get <Graphic_Multi>(pawnGraphicSet.nakedGraphic.path + "Pack", ShaderDatabase.Cutout, pawnGraphicSet.nakedGraphic.drawSize, Color.white); } if (curKindLifeStage.dessicatedBodyGraphicData != null) { pawnGraphicSet.dessicatedGraphic = curKindLifeStage.dessicatedBodyGraphicData.GraphicColoredFor(lumberer); } //pawnRenderer.RenderPawnAt(lumberer.Position.ToVector3()); } } } } }
// ResolveApparelGraphics Detour internal static void _ResolveApparelGraphics(this PawnGraphicSet _this) { // Updates the beard if (_this.pawn.apparel.BodyPartGroupIsCovered(BodyPartGroupDefOf.UpperHead)) { ResolveAgeGraphics(_this); } _this.ClearCache(); _this.apparelGraphics.Clear(); BodyType btype = BodyType.Male; if (_this.pawn.ageTracker.CurLifeStageIndex == 2) { btype = BodyType.Thin; } if (_this.pawn.apparel.WornApparelCount > 0) { foreach (Apparel current in _this.pawn.apparel.WornApparelInDrawOrder) { ApparelGraphicRecord item; if (current.AllComps.Any(i => i.GetType() == typeof(CompFactionColor))) { if (ApparelGraphicGetterFC.TryGetGraphicApparelModded(current, btype, out item)) { _this.apparelGraphics.Add(item); } } else if (ApparelGraphicRecordGetter.TryGetGraphicApparel(current, _this.pawn.story.bodyType, out item)) { _this.apparelGraphics.Add(item); } } } }
private static bool PawnGraphicSet_ResolveAllGraphics_prefix(PawnGraphicSet __instance) { if (__instance.pawn.RaceProps.Animal) { Pawn pawn = __instance.pawn; PawnKindLifeStage curKindLifeStage = __instance.pawn.ageTracker.CurKindLifeStage; Graphic baseGraphic = pawn.gender != Gender.Female || curKindLifeStage.femaleGraphicData == null ? curKindLifeStage.bodyGraphicData.Graphic : curKindLifeStage.femaleGraphicData.Graphic; Color color = baseGraphic.color; Color ColorTwo = baseGraphic.colorTwo; Shader shader = ShaderDatabase.Cutout; if (__instance.pawn.ageTracker.CurKindLifeStage.bodyGraphicData.graphicClass == typeof(Graphic_MultiRandom)) { int TextureCountTotal = TextureCount(baseGraphic.path); if (TextureCountTotal > 0) { int textureIndex = (new System.Random(pawn.thingIDNumber * 2)).Next() % TextureCountTotal; string safeTextureIndex = (1 + textureIndex).ToString(); __instance.ClearCache(); if (curKindLifeStage.dessicatedBodyGraphicData is GraphicData dessicated) { __instance.dessicatedGraphic = dessicated.GraphicColoredFor(__instance.pawn); } __instance.nakedGraphic = (new Graphic_MultiRandom(baseGraphic)).GetColoredVersion(ShaderDatabase.ShaderFromType(shader), color, safeTextureIndex); return false; } } return true; } return true; }
public static bool RenderWerewolf(PawnGraphicSet __instance) { Pawn p = __instance.pawn; if (p?.GetComp <CompWerewolf>() is CompWerewolf compWerewolf && compWerewolf.IsTransformed) { __instance.ClearCache(); if (compWerewolf.CurrentWerewolfForm.bodyGraphicData == null || __instance.nakedGraphic == null) { compWerewolf.CurrentWerewolfForm.bodyGraphicData = compWerewolf.CurrentWerewolfForm.def.graphicData; __instance.nakedGraphic = GraphicDatabase.Get <Graphic_Multi>( path: compWerewolf.CurrentWerewolfForm.bodyGraphicData.texPath, shader: ShaderDatabase.Cutout, drawSize: compWerewolf.CurrentWerewolfForm.bodyGraphicData.drawSize, color: WerewolfColor(p, compWerewolf.CurrentWerewolfForm)); __instance.headGraphic = null; __instance.hairGraphic = null; } return(false); } return(true); }
// [HarmonyAfter("net.pardeike.zombieland")] public static void ResolveAllGraphics_Postfix(PawnGraphicSet __instance) { Pawn pawn = __instance.pawn; if (pawn == null) { return; } pawn.CheckForAddedOrMissingParts(); pawn.GetCompAnim()?.PawnBodyGraphic?.Initialize(); // Check if race has face, else return if (!pawn.GetCompFace(out CompFace compFace)) { return; } compFace.IsChild = pawn.ageTracker.AgeBiologicalYearsFloat < 14; // Return if child if (compFace.IsChild || compFace.Deactivated) { return; } __instance.ClearCache(); pawn.GetComp <CompBodyAnimator>()?.ClearCache(); GraphicDatabaseHeadRecordsModded.BuildDatabaseIfNecessary(); // Need: get the traditional habitat of a faction => not suitable, as factions are scattered around the globe // if (!faceComp.IsSkinDNAoptimized) // { // faceComp.DefineSkinDNA(); // } // Custom rotting color, mixed with skin tone Color rotColor = pawn.story.SkinColor * FaceTextures.SkinRottingMultiplyColor; if (!compFace.InitializeCompFace()) { return; } __instance.nakedGraphic = GraphicDatabase.Get <Graphic_Multi>(__instance.pawn.story.bodyType.bodyNakedGraphicPath, ShaderDatabase.CutoutSkin, Vector2.one, __instance.pawn.story.SkinColor); if (compFace.Props.needsBlankHumanHead) { __instance.headGraphic = GraphicDatabaseHeadRecordsModded.GetModdedHeadNamed(pawn, pawn.story.SkinColor); __instance.desiccatedHeadGraphic = GraphicDatabaseHeadRecordsModded.GetModdedHeadNamed(pawn, rotColor); __instance.desiccatedHeadStumpGraphic = GraphicDatabaseHeadRecordsModded.GetStump(rotColor); } __instance.rottingGraphic = GraphicDatabase.Get <Graphic_Multi>(__instance.pawn.story.bodyType.bodyNakedGraphicPath, ShaderDatabase.CutoutSkin, Vector2.one, rotColor); __instance.hairGraphic = GraphicDatabase.Get <Graphic_Multi_Four>( pawn.story.hairDef.texPath, ShaderDatabase.CutoutComplex, Vector2.one, pawn.story.hairColor); PortraitsCache.SetDirty(pawn); }
private static bool Prefix(PawnGraphicSet __instance) { if (__instance.pawn.def is RaceAddonThingDef thingDef) { Pawn pawn = __instance.pawn; RaceAddonComp racomp = pawn.GetComp <RaceAddonComp>(); racomp.drawSize = RaceAddonTools.GetPawnDrawSize(pawn, thingDef); var drawSize = thingDef.raceAddonSettings.graphicSetting.drawSize[racomp.drawSize]; // cleaning __instance.ClearCache(); // resolve mesh set racomp.bodyMeshSet = new GraphicMeshSet(1.5f * drawSize.bodySize.x, 1.5f * drawSize.bodySize.y); racomp.headMeshSet = new GraphicMeshSet(1.5f * drawSize.headSize.x, 1.5f * drawSize.headSize.y); racomp.equipmentMeshSet = new GraphicMeshSet(drawSize.equipmentSize.x, drawSize.equipmentSize.y); // resolve body var bodyDef = racomp.savedBodyData.def; __instance.pawn.story.bodyType = bodyDef.bodyTypeDef; __instance.nakedGraphic = GraphicDatabase.Get <Graphic_Multi> (GetBodyNormalPath(bodyDef), bodyDef.shaderType.Shader, Vector2.one, pawn.story.SkinColor, racomp.savedSkinData.color2); __instance.rottingGraphic = GraphicDatabase.Get <Graphic_Multi> (GetBodyNormalPath(bodyDef), bodyDef.shaderType.Shader, Vector2.one, racomp.savedSkinData.rottingColor); __instance.dessicatedGraphic = GraphicDatabase.Get <Graphic_Multi>(GetBodySkullPath(bodyDef), ShaderDatabase.Cutout); // resolve head var headDef = racomp.savedHeadData.def; __instance.pawn.story.crownType = headDef.crownType; __instance.headGraphic = GraphicDatabase.Get <Graphic_Multi> (headDef.replacedHeadPath, headDef.shaderType.Shader, Vector2.one, pawn.story.SkinColor, racomp.savedSkinData.color2); __instance.desiccatedHeadGraphic = GraphicDatabase.Get <Graphic_Multi> (headDef.replacedHeadPath, headDef.shaderType.Shader, Vector2.one, racomp.savedSkinData.rottingColor); __instance.skullGraphic = GraphicDatabase.Get <Graphic_Multi> (headDef.replacedSkullPath, headDef.shaderType.Shader, Vector2.one, Color.white); // resolve stump __instance.headStumpGraphic = GraphicDatabase.Get <Graphic_Multi> (headDef.replacedStumpPath, headDef.shaderType.Shader, Vector2.one, pawn.story.SkinColor, racomp.savedSkinData.color2); __instance.desiccatedHeadStumpGraphic = GraphicDatabase.Get <Graphic_Multi> (headDef.replacedStumpPath, headDef.shaderType.Shader, Vector2.one, racomp.savedSkinData.rottingColor); // resolve hair HairDef hairDef = pawn.story.hairDef; if (hairDef is ImprovedHairDef advancedHairDef) { __instance.hairGraphic = GraphicDatabase.Get <Graphic_Multi> (advancedHairDef.texPath, advancedHairDef.shaderType.Shader, Vector2.one, pawn.story.hairColor, racomp.savedHairData.color2); if (advancedHairDef.lowerPath != null) { racomp.improvedHairGraphic = GraphicDatabase.Get <Graphic_Multi> (advancedHairDef.lowerPath, advancedHairDef.shaderType.Shader, Vector2.one, pawn.story.hairColor, racomp.savedHairData.color2); } } else { __instance.hairGraphic = GraphicDatabase.Get <Graphic_Multi> (hairDef.texPath, ShaderDatabase.Cutout, Vector2.one, pawn.story.hairColor); racomp.improvedHairGraphic = null; } // resolve upper face if (racomp.savedFaceData != null && racomp.savedFaceData.upperDef != null) { var upperFaceDef = racomp.savedFaceData.upperDef; racomp.upperFaceGraphicSet = new FaceGraphicSet(pawn, racomp.savedFaceData, upperFaceDef, racomp); racomp.upperFaceGraphicSet.ResolveAllGraphics(); } // resolve lower face if (racomp.savedFaceData != null && racomp.savedFaceData.lowerDef != null) { var lowerFaceDef = racomp.savedFaceData.lowerDef; racomp.lowerFaceGraphicSet = new FaceGraphicSet(pawn, racomp.savedFaceData, lowerFaceDef, racomp); racomp.lowerFaceGraphicSet.ResolveAllGraphics(); } // resolve addons if (racomp.savedAddonDatas != null) { racomp.bodyAddonGraphicSets = null; racomp.headAddonGraphicSets = null; foreach (var data in racomp.savedAddonDatas) { if (data.def.drawingToBody) { if (racomp.bodyAddonGraphicSets == null) { racomp.bodyAddonGraphicSets = new List <AddonGraphicSet>(); } var set = new AddonGraphicSet(data); set.ResolveAllGraphics(racomp.savedSkinData.rottingColor, pawn.health.hediffSet); racomp.bodyAddonGraphicSets.Add(set); } else { if (racomp.headAddonGraphicSets == null) { racomp.headAddonGraphicSets = new List <AddonGraphicSet>(); } var set = new AddonGraphicSet(data); set.ResolveAllGraphics(racomp.savedSkinData.rottingColor, pawn.health.hediffSet); racomp.headAddonGraphicSets.Add(set); } } } if (!pawn.Dead) { // resolve eye blinker if (thingDef.raceAddonSettings.graphicSetting.eyeBlink) { racomp.eyeBlinker = new EyeBlinker(); racomp.eyeBlinker.Check(pawn.needs.mood.CurLevel); } // resolve head rotator if (thingDef.raceAddonSettings.graphicSetting.headAnimation) { racomp.headRotator = new HeadRotator(); racomp.headRotator.Check(); } // resolve head targeter if (thingDef.raceAddonSettings.graphicSetting.headTargeting) { racomp.headTargeter = new HeadTargeter(__instance.pawn); racomp.headTargeter.Check(); } } // resolve apparel __instance.ResolveApparelGraphics(); return(false); } return(true); }
public static bool Prefix(PawnGraphicSet __instance) { if (__instance.pawn.RaceProps.Animal) { bool isCustom = false; Pawn pawn = __instance.pawn; PawnKindLifeStage curKindLifeStage = __instance.pawn.ageTracker.CurKindLifeStage; Graphic baseGraphic = new Graphic(((pawn.gender == Gender.Female) ? curKindLifeStage.femaleGraphicData?.Graphic ?? curKindLifeStage.bodyGraphicData.Graphic : curKindLifeStage.bodyGraphicData.Graphic)); if (baseGraphic is null) { Debug.Log("Basegraphic for " + pawn.ThingID + " null"); return(true); } Color color = baseGraphic.color; /*if (baseGraphic.Shader.name != ShaderType.Cutout.ToString()) { * Log.Error("boutta override " + pawn.Label + "'s " + baseGraphic.Shader.name + " with cutoutskin :("); * }*/ Shader shader = ShaderDatabase.Cutout; //has custom colors Debug.Log("Checking custom color " + pawn.Label); if (__instance.pawn.kindDef.GetModExtension <BPTModExtension>() is BPTModExtension extension) { isCustom = true; int colorIndex = (new System.Random(pawn.thingIDNumber)).Next() % extension.colors.Count; color = extension.colors[colorIndex]; FieldInfo fieldInfo = typeof(ShaderDatabase).GetField(extension.shaderType, BindingFlags.Static | BindingFlags.Public); shader = (Shader)fieldInfo.GetValue(null); Debug.Log("chose special color " + color + " with shader " + shader); Debug.Log(typeof(ShaderDatabase).GetFields(BindingFlags.Static | BindingFlags.Public).ToStringSafeEnumerable()); } else { Debug.Log(__instance.pawn.kindDef.GetModExtension <BPTModExtension>().ToStringSafe()); } string safeTextureIndex = ""; //has custom texture Debug.Log("Checking custom texture " + pawn.Label); if (__instance.pawn.ageTracker.CurKindLifeStage.bodyGraphicData.graphicClass == typeof(Graphic)) { isCustom = true; int availableTextureCount = Graphic.ModTextureCount(baseGraphic.path); if (availableTextureCount > 0) { int textureIndex = (new System.Random(pawn.thingIDNumber * 2)).Next() % availableTextureCount; safeTextureIndex = (1 + textureIndex).ToString(); } Debug.Log("chose texture " + safeTextureIndex); } if (isCustom) { __instance.ClearCache(); if (curKindLifeStage.dessicatedBodyGraphicData is GraphicData dessicated) { __instance.dessicatedGraphic = dessicated.GraphicColoredFor(__instance.pawn); } //may spawn packs all default colors if (pawn.RaceProps.packAnimal) { Debug.Log("pack animal with shader:" + shader.ToStringSafe() + color.ToStringSafe()); __instance.packGraphic = GraphicDatabase.Get <Graphic_Multi>(Graphic.PathBase(baseGraphic.path) + "Pack", shader, baseGraphic.drawSize, color); } __instance.nakedGraphic = (new Graphic(baseGraphic)).GetColoredVersion(shader, color, safeTextureIndex); Debug.Log("Resolved " + __instance.nakedGraphic); return(false); } return(true); } return(true); }