// Taken from RenderingTool.RenderPawnInternal in CharacterEditor private void RenderPawn() { PawnGraphicSet graphics = pawn.Drawer.renderer.graphics; Quaternion quaternion = Quaternion.AngleAxis(0f, Vector3.up); Mesh bodyMesh = pawn.RaceProps.Humanlike ? MeshPool.humanlikeBodySet.MeshAt(previewRot) : graphics.nakedGraphic.MeshAt(previewRot); Vector3 bodyOffset = new Vector3(0f, pawn.Position.y + 0.007575758f, 0f); foreach (Material mat in graphics.MatsBodyBaseAt(previewRot)) { Material damagedMat = graphics.flasher.GetDamagedMat(mat); GenDraw.DrawMeshNowOrLater(bodyMesh, bodyOffset, quaternion, damagedMat, false); bodyOffset.y += 0.00390625f; if (!toggleClothesEnabled) { break; } } Vector3 vector3 = new Vector3(0f, pawn.Position.y + (previewRot == Rot4.North ? 0.026515152f : 0.022727273f), 0f); Vector3 vector4 = new Vector3(0f, pawn.Position.y + (previewRot == Rot4.North ? 0.022727273f : 0.026515152f), 0f); if (graphics.headGraphic != null) { Mesh mesh2 = MeshPool.humanlikeHeadSet.MeshAt(previewRot); Vector3 headOffset = quaternion * pawn.Drawer.renderer.BaseHeadOffsetAt(previewRot); Material material = graphics.HeadMatAt_NewTemp(previewRot); GenDraw.DrawMeshNowOrLater(mesh2, vector4 + headOffset, quaternion, material, false); Mesh hairMesh = graphics.HairMeshSet.MeshAt(previewRot); Vector3 hairOffset = new Vector3(headOffset.x, pawn.Position.y + 0.030303031f, headOffset.z); bool isWearingHat = false; if (toggleClothesEnabled) { foreach (ApparelGraphicRecord apparel in graphics.apparelGraphics) { if (apparel.sourceApparel.def.apparel.LastLayer == ApparelLayerDefOf.Overhead) { Material hatMat = graphics.flasher.GetDamagedMat(apparel.graphic.MatAt(previewRot)); if (apparel.sourceApparel.def.apparel.hatRenderedFrontOfFace) { isWearingHat = true; hairOffset.y += 0.03f; GenDraw.DrawMeshNowOrLater(hairMesh, hairOffset, quaternion, hatMat, false); } else { Vector3 hatOffset = new Vector3(headOffset.x, pawn.Position.y + (previewRot == Rot4.North ? 0.003787879f : 0.03409091f), headOffset.z); GenDraw.DrawMeshNowOrLater(hairMesh, hatOffset, quaternion, hatMat, false); } } } } if (!isWearingHat) { Material hairMat = graphics.HairMatAt_NewTemp(previewRot); GenDraw.DrawMeshNowOrLater(hairMesh, hairOffset, quaternion, hairMat, false); } } if (toggleClothesEnabled) { foreach (ApparelGraphicRecord graphicsSet in graphics.apparelGraphics) { if (graphicsSet.sourceApparel.def.apparel.LastLayer == ApparelLayerDefOf.Shell) { Material clothingMat = graphics.flasher.GetDamagedMat(graphicsSet.graphic.MatAt(previewRot)); GenDraw.DrawMeshNowOrLater(bodyMesh, vector3, quaternion, clothingMat, false); } } } HarmonyPatches.DrawAddons(false, vector3, pawn, quaternion, previewRot, false); if (toggleClothesEnabled) { if (pawn.apparel != null) { foreach (Apparel apparel in pawn.apparel.WornApparel) { apparel.DrawWornExtras(); } } } }