public GraphicMeshSet MeshSet(Pawn pawn) { if (apparel?.Wearer == null) { return(new GraphicMeshSet(1.5f, 1.5f)); } if (meshSet == null) { meshSet = new GraphicMeshSet(size.x, size.y); } return(meshSet); }
public RaceAddonGraphicSet(Pawn pawn, RaceAddonComp racomp) { if (pawn.def is RaceAddonThingDef thingDef) { this.pawn = pawn; this.racomp = racomp; presentAgeSetting = thingDef.raceAddonSettings.ageSettings.GetPresent(pawn); headMeshSet = new GraphicMeshSet((1.5f * presentAgeSetting.drawSize.head.x) * racomp.drawSizeDeviation, (1.5f * presentAgeSetting.drawSize.head.y) * racomp.drawSizeDeviation); bodyMeshSet = new GraphicMeshSet((1.5f * presentAgeSetting.drawSize.body.x) * racomp.drawSizeDeviation, (1.5f * presentAgeSetting.drawSize.body.y) * racomp.drawSizeDeviation); //equipmentMeshSet = new GraphicMeshSet(presentAgeSetting.drawSize.equipment.x, presentAgeSetting.drawSize.equipment.y); racomp.cachedDrawLocCorrection = 0f; if (thingDef.raceAddonSettings.graphicSetting.footPositionCorrection_DrawSize) { racomp.cachedDrawLocCorrection += (1.5f - (1.5f * presentAgeSetting.drawSize.body.y)) / 2f; } if (thingDef.raceAddonSettings.graphicSetting.footPositionCorrection_DrawSizeCurve) { racomp.cachedDrawLocCorrection += (1.5f - (1.5f * racomp.drawSizeDeviation)) / 2f; } eyeBlinker = thingDef.raceAddonSettings.graphicSetting.eyeBlink ? new EyeBlinker() : null; headRotator = thingDef.raceAddonSettings.graphicSetting.headAnimation ? new HeadRotator() : null; headTargeter = thingDef.raceAddonSettings.graphicSetting.headTargeting ? new HeadTargeter(pawn) : null; upperFaceGraphic = racomp.upperFaceDef == null ? null : new FaceGraphicRecord(pawn, racomp.upperFaceDef, racomp.faceColor_Main, racomp.faceColor_Sub, thingDef.raceAddonSettings.graphicSetting.fixedUpperFace); lowerFaceGraphic = racomp.lowerFaceDef == null ? null : new FaceGraphicRecord(pawn, racomp.lowerFaceDef, racomp.faceColor_Main, racomp.faceColor_Sub, thingDef.raceAddonSettings.graphicSetting.fixedLowerFace); foreach (var addonData in racomp.addonDatas) { var linkedBodyPart = addonData.addonDef.linkedBodyPart.GetBodyPartRecord(pawn.def.race.body); addonGraphics.Add(new AddonGraphicRecord(addonData, linkedBodyPart, thingDef.raceAddonSettings.graphicSetting.rottingColor)); } } else { RaceAddon.Notify("RaceAddonGraphicSet Init failure, Unkown ThingDef => " + pawn.Name.ToStringShort, true); } }
public void GenerateMeshsAndMeshPools() { { if (!meshPools.Keys.Any(v => v.Equals(this.customDrawSize))) { meshPools.Add(this.customDrawSize, new GraphicMeshSet[] { new GraphicMeshSet(1.5f * this.customDrawSize.x, 1.5f * this.customDrawSize.y), // bodySet new GraphicMeshSet(1.5f * this.customDrawSize.x, 1.5f * this.customDrawSize.y), // headSet new GraphicMeshSet(1.5f * this.customDrawSize.x, 1.5f * this.customDrawSize.y), // hairSetAverage new GraphicMeshSet(1.3f * this.customDrawSize.x, 1.5f * this.customDrawSize.y), // hairSetNarrow }); } GraphicMeshSet[] meshSet = meshPools[meshPools.Keys.First(v => v.Equals(this.customDrawSize))]; this.bodySet = meshSet[0]; this.headSet = meshSet[1]; this.hairSetAverage = meshSet[2]; this.hairSetNarrow = meshSet[3]; this.bodyAddons.ForEach(ba => { ba.addonMesh = (Mesh)meshInfo.Invoke(null, new object[] { this.customDrawSize * 1.5f, false, false, false }); ba.addonMeshFlipped = (Mesh)meshInfo.Invoke(null, new object[] { this.customDrawSize * 1.5f, true, false, false }); }); } { if (!meshPools.Keys.Any(v => v.Equals(this.customPortraitDrawSize))) { meshPools.Add(this.customPortraitDrawSize, new GraphicMeshSet[] { new GraphicMeshSet(1.5f * this.customPortraitDrawSize.x, 1.5f * this.customPortraitDrawSize.y), // bodySet new GraphicMeshSet(1.5f * this.customPortraitDrawSize.x, 1.5f * this.customPortraitDrawSize.y), // headSet new GraphicMeshSet(1.5f * this.customPortraitDrawSize.x, 1.5f * this.customPortraitDrawSize.y), // hairSetAverage new GraphicMeshSet(1.3f * this.customPortraitDrawSize.x, 1.5f * this.customPortraitDrawSize.y), // hairSetNarrow }); } GraphicMeshSet[] meshSet = meshPools[meshPools.Keys.First(v => v.Equals(this.customPortraitDrawSize))]; this.bodyPortraitSet = meshSet[0]; this.headPortraitSet = meshSet[1]; this.hairPortraitSetAverage = meshSet[2]; this.hairPortraitSetNarrow = meshSet[3]; this.bodyAddons.ForEach(ba => { ba.addonPortraitMesh = (Mesh)meshInfo.Invoke(null, new object[] { this.customPortraitDrawSize * 1.5f, false, false, false }); ba.addonPortraitMeshFlipped = (Mesh)meshInfo.Invoke(null, new object[] { this.customPortraitDrawSize * 1.5f, true, false, false }); }); } { this.bodyAddons.Do(ba => { if (ba.variantCount == 0) { while (ContentFinder <Texture2D> .Get(ba.path + (ba.variantCount == 0 ? "" : ba.variantCount.ToString()) + "_back", false) != null) { ba.variantCount++; } Log.Message("Variants found for " + ba.path + ": " + ba.variantCount.ToString()); if (ba.hediffGraphics != null) { foreach (BodyAddonHediffGraphic bahg in ba.hediffGraphics) { if (bahg.variantCount == 0) { while (ContentFinder <Texture2D> .Get(bahg.path + (bahg.variantCount == 0 ? "" : bahg.variantCount.ToString()) + "_back", false) != null) { bahg.variantCount++; } Log.Message("Variants found for " + bahg.path + ": " + bahg.variantCount.ToString()); } } } if (ba.backstoryGraphics != null) { foreach (BodyAddonBackstoryGraphic babg in ba.backstoryGraphics) { if (babg.variantCount == 0) { while (ContentFinder <Texture2D> .Get(babg.path + (babg.variantCount == 0 ? "" : babg.variantCount.ToString()) + "_back", false) != null) { babg.variantCount++; } Log.Message("Variants found for " + babg.path + ": " + babg.variantCount.ToString()); } } } } }); } }
private void RenderPawnInternal(Vector3 rootLoc, float angle, bool renderBody, Rot4 bodyFacing, Rot4 headFacing, RotDrawMode bodyDrawType, bool portrait , bool headStump, bool invisible, int curLevel, int baseLevel) { if (!this.graphics.AllResolved) { this.graphics.ResolveAllGraphics(); } float scaledSize = 1.5f * (1f - ((curLevel - baseLevel) / DrawDynamicThings.pawnDrawScale)); Quaternion quaternion = Quaternion.AngleAxis(angle, Vector3.up); Mesh mesh = null; if (renderBody) { Vector3 loc = rootLoc; loc.y += 0.007575758f; if (bodyDrawType == RotDrawMode.Dessicated && !this.pawn.RaceProps.Humanlike && this.graphics.dessicatedGraphic != null && !portrait) { this.graphics.dessicatedGraphic.Draw(loc, bodyFacing, this.pawn, angle); } else { if (this.pawn.RaceProps.Humanlike) { mesh = new GraphicMeshSet(scaledSize).MeshAt(bodyFacing); } else { Vector2 drawSize = this.graphics.nakedGraphic.drawSize; drawSize.x *= 1f - ((curLevel - baseLevel) / DrawDynamicThings.pawnDrawScale); drawSize.y *= 1f - ((curLevel - baseLevel) / DrawDynamicThings.pawnDrawScale); var newGraphic = this.graphics.nakedGraphic.GetCopy(drawSize); mesh = newGraphic.MeshAt(bodyFacing); } List <Material> list = this.graphics.MatsBodyBaseAt(bodyFacing, bodyDrawType); for (int i = 0; i < list.Count; i++) { Material mat = this.OverrideMaterialIfNeeded(list[i], this.pawn); GenDraw.DrawMeshNowOrLater(mesh, loc, quaternion, mat, portrait); loc.y += 0.003787879f; } if (bodyDrawType == RotDrawMode.Fresh) { Vector3 drawLoc = rootLoc; drawLoc.y += 0.0189393945f; this.woundOverlays.RenderOverBody(drawLoc, mesh, quaternion, portrait); } } } Vector3 vector = rootLoc; Vector3 a = rootLoc; if (bodyFacing != Rot4.North) { a.y += 0.0265151523f; vector.y += 0.0227272734f; } else { a.y += 0.0227272734f; vector.y += 0.0265151523f; } if (this.graphics.headGraphic != null) { Vector3 b = (quaternion * this.BaseHeadOffsetAt(headFacing)) * (1f - ((curLevel - baseLevel) / DrawDynamicThings.pawnDrawScale)); Material material = this.graphics.HeadMatAt(headFacing, bodyDrawType, headStump); if (material != null) { GenDraw.DrawMeshNowOrLater(new GraphicMeshSet(scaledSize).MeshAt(headFacing), a + b, quaternion, material, portrait); } Vector3 loc2 = rootLoc + b; loc2.y += 0.0303030312f; bool flag = false; if (!portrait || !Prefs.HatsOnlyOnMap) { Mesh mesh2 = new GraphicMeshSet(scaledSize).MeshAt(headFacing); List <ApparelGraphicRecord> apparelGraphics = this.graphics.apparelGraphics; for (int j = 0; j < apparelGraphics.Count; j++) { if (apparelGraphics[j].sourceApparel.def.apparel.LastLayer == ApparelLayerDefOf.Overhead) { if (!apparelGraphics[j].sourceApparel.def.apparel.hatRenderedFrontOfFace) { flag = true; Material material2 = apparelGraphics[j].graphic.MatAt(bodyFacing, null); material2 = this.OverrideMaterialIfNeeded(material2, this.pawn); GenDraw.DrawMeshNowOrLater(mesh2, loc2, quaternion, material2, portrait); } else { Material material3 = apparelGraphics[j].graphic.MatAt(bodyFacing, null); material3 = this.OverrideMaterialIfNeeded(material3, this.pawn); Vector3 loc3 = rootLoc + b; loc3.y += ((bodyFacing == Rot4.North) ? 0.003787879f : 0.03409091f); GenDraw.DrawMeshNowOrLater(mesh2, loc3, quaternion, material3, portrait); } } } } if (!flag && bodyDrawType != RotDrawMode.Dessicated && !headStump) { Mesh mesh3 = new GraphicMeshSet(scaledSize).MeshAt(headFacing); Material mat2 = this.graphics.HairMatAt(headFacing); GenDraw.DrawMeshNowOrLater(mesh3, loc2, quaternion, mat2, portrait); } } if (renderBody) { for (int k = 0; k < this.graphics.apparelGraphics.Count; k++) { ApparelGraphicRecord apparelGraphicRecord = this.graphics.apparelGraphics[k]; if (apparelGraphicRecord.sourceApparel.def.apparel.LastLayer == ApparelLayerDefOf.Shell) { Material material4 = apparelGraphicRecord.graphic.MatAt(bodyFacing, null); material4 = this.OverrideMaterialIfNeeded(material4, this.pawn); GenDraw.DrawMeshNowOrLater(mesh, vector, quaternion, material4, portrait); } } } if (!portrait && this.pawn.RaceProps.Animal && this.pawn.inventory != null && this.pawn.inventory.innerContainer.Count > 0 && this.graphics.packGraphic != null) { Graphics.DrawMesh(mesh, vector, quaternion, this.graphics.packGraphic.MatAt(bodyFacing, null), 0); } if (!portrait) { this.DrawEquipment(rootLoc, curLevel, baseLevel); if (this.pawn.apparel != null) { List <Apparel> wornApparel = this.pawn.apparel.WornApparel; for (int l = 0; l < wornApparel.Count; l++) { wornApparel[l].DrawWornExtras(); } } Vector3 bodyLoc = rootLoc; bodyLoc.y += 0.0416666679f; this.statusOverlays.RenderStatusOverlays(bodyLoc, quaternion, MeshPool.humanlikeHeadSet.MeshAt(headFacing)); } }
public GraphicVectorMeshSet(float sizeX, float sizeY, Vector2 offSet) { this.Mesh = new GraphicMeshSet(sizeX, sizeY); this._offSet = offSet; }
public static void Postfix(PawnRenderer __instance, ref Pawn __state, Vector3 rootLoc, float angle, bool renderBody, Rot4 bodyFacing, Rot4 headFacing, RotDrawMode bodyDrawType, bool portrait, bool headStump) { if (__state != null && __instance.graphics.headGraphic != null) { #if DEBUG bool isPawn = false; if (__state.Faction.def == FactionDefOf.PlayerColony || __state.Faction.def == FactionDefOf.PlayerTribe) { isPawn = __state.Name.ToStringShort.Equals("Happy"); } #endif Quaternion quad = Quaternion.AngleAxis(angle, Vector3.up); Vector3 b = quad * __instance.BaseHeadOffsetAt(headFacing); Vector3 loc2 = rootLoc + b; bool forceShowHair = false; bool hideHats = HideHats(portrait); float hairLoc = 0; bool flag = false; List <ApparelGraphicRecord> apparelGraphics = __instance.graphics.apparelGraphics; for (int j = 0; j < apparelGraphics.Count; j++) { Apparel sourceApparel = apparelGraphics[j].sourceApparel; if (sourceApparel.def.apparel.LastLayer == ApparelLayerDefOf.Overhead) { #if DEBUG && T int i = 10324; Log.ErrorOnce("---hats:", i); ++i; foreach (KeyValuePair <ThingDef, bool> kv in Settings.HatsThatHide) { Log.ErrorOnce(kv.Key + " " + kv.Value, i); ++i; } Log.ErrorOnce("---Hair:", i); ++i; foreach (KeyValuePair <HairDef, bool> kv in Settings.HairThatShows) { Log.ErrorOnce(kv.Key + " " + kv.Value, i); ++i; } #endif #if DEBUG if (isPawn) { if (!Settings.HatsThatHide.TryGetValue(sourceApparel.def, out bool bb)) { bb = false; } Log.Warning("Force no hair --- HatsThatHide[" + sourceApparel.def + "] = " + bb); } #endif if (!hideHats) { if (!Settings.HatsThatHide.TryGetValue(sourceApparel.def, out bool force)) { force = false; } forceShowHair = !force; } if (!sourceApparel.def.apparel.hatRenderedFrontOfFace) { flag = true; loc2.y += 0.03125f; hairLoc = loc2.y; } else { Vector3 loc3 = rootLoc + b; loc3.y += ((!(bodyFacing == Rot4.North)) ? 0.03515625f : 0.00390625f); hairLoc = loc3.y; } } } #if DEBUG && T if (isPawn && pawn.Name.ToStringShort.Equals("Happy")) { Log.Warning(pawn.Name.ToStringShort + " Hair: " + pawn.story.hairDef.defName + " HideAllHats: " + Settings.HideAllHats + " forceShowHair: " + forceShowHair + " flag: " + flag + " bodyDrawType: " + bodyDrawType + " headStump: " + headStump); } #endif if ((!flag && bodyDrawType != RotDrawMode.Dessicated && !headStump) || (!hideHats && Settings.HairToHide.TryGetValue(__state.story.hairDef, out bool v) && v)) { // Hair was already rendered } else if ((hideHats || forceShowHair) && hairLoc > 0) { if (hairLoc > 0.001f) { loc2.y = hairLoc - 0.001f; Material mat = __instance.graphics.HairMatAt(headFacing); if (getBodySizeScalingMI != null && getModifiedHairMeshSetMI != null) { Vector3 scaledHairLoc = new Vector3(b.x, b.y, b.z); float scale = (float)getBodySizeScalingMI.Invoke(null, new object[] { __state.ageTracker.CurLifeStage.bodySizeFactor, __state }); scaledHairLoc.x *= scale; scaledHairLoc.z *= scale; scaledHairLoc += rootLoc; scaledHairLoc.y = loc2.y; GraphicMeshSet meshSet = (GraphicMeshSet)getModifiedHairMeshSetMI.Invoke(null, new object[] { scale, __state }); GenDraw.DrawMeshNowOrLater(meshSet.MeshAt(headFacing), scaledHairLoc, quad, mat, portrait); } else { GenDraw.DrawMeshNowOrLater(__instance.graphics.HairMeshSet.MeshAt(headFacing), loc2, quad, mat, portrait); } } } } }