public override List<Material> BodyBaseAt( [NotNull] PawnGraphicSet graphics, Rot4 bodyFacing, RotDrawMode bodyDrawType, MaxLayerToShow layer) { switch (layer) { case MaxLayerToShow.Naked: return this.CompAnimator?.NakedMatsBodyBaseAt(bodyFacing, bodyDrawType); case MaxLayerToShow.OnSkin: return this.CompAnimator?.UnderwearMatsBodyBaseAt(bodyFacing, bodyDrawType); default: return graphics.MatsBodyBaseAt(bodyFacing, bodyDrawType); } return base.BodyBaseAt(graphics, bodyFacing, bodyDrawType, layer); }
// 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(); } } } }
public virtual void DrawInnerThing(Pawn pawn, Vector3 rootLoc, float angle, bool renderBody, Rot4 bodyFacing, Rot4 headFacing, RotDrawMode bodyDrawType, bool portrait, bool headStump) { PawnGraphicSet graphics = pawn.Drawer.renderer.graphics; PawnRenderer renderer = pawn.Drawer.renderer; if (!graphics.AllResolved) { graphics.ResolveAllGraphics(); } Quaternion quaternion = Quaternion.AngleAxis(angle, Vector3.up); Mesh mesh = null; if (renderBody) { Vector3 loc = rootLoc; loc.y += 0.0078125f; if (bodyDrawType == RotDrawMode.Dessicated && !pawn.RaceProps.Humanlike && graphics.dessicatedGraphic != null && !portrait) { graphics.dessicatedGraphic.Draw(loc, bodyFacing, pawn, angle); } else { if (pawn.RaceProps.Humanlike) { mesh = MeshPool.humanlikeBodySet.MeshAt(bodyFacing); } else { mesh = graphics.nakedGraphic.MeshAt(bodyFacing); } List <Material> list = graphics.MatsBodyBaseAt(bodyFacing, bodyDrawType); for (int i = 0; i < list.Count; i++) { Material damagedMat = graphics.flasher.GetDamagedMat(list[i]); GenDraw.DrawMeshNowOrLater(mesh, loc, quaternion, damagedMat, portrait); loc.y += 0.00390625f; } } } Vector3 vector = rootLoc; Vector3 a = rootLoc; if (bodyFacing != Rot4.North) { a.y += 0.02734375f; vector.y += 0.0234375f; } else { a.y += 0.0234375f; vector.y += 0.02734375f; } if (graphics.headGraphic != null) { Vector3 b = quaternion * renderer.BaseHeadOffsetAt(headFacing); Material material = graphics.HeadMatAt(headFacing, bodyDrawType, headStump); if (material != null) { Mesh mesh2 = MeshPool.humanlikeHeadSet.MeshAt(headFacing); GenDraw.DrawMeshNowOrLater(mesh2, a + b, quaternion, material, portrait); } Vector3 loc2 = rootLoc + b; loc2.y += 0.03125f; bool flag = false; if (!portrait || !Prefs.HatsOnlyOnMap) { Mesh mesh3 = graphics.HairMeshSet.MeshAt(headFacing); List <ApparelGraphicRecord> apparelGraphics = 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 = graphics.flasher.GetDamagedMat(material2); GenDraw.DrawMeshNowOrLater(mesh3, loc2, quaternion, material2, portrait); } else { Material material3 = apparelGraphics[j].graphic.MatAt(bodyFacing, null); material3 = graphics.flasher.GetDamagedMat(material3); Vector3 loc3 = rootLoc + b; loc3.y += ((!(bodyFacing == Rot4.North)) ? 0.03515625f : 0.00390625f); GenDraw.DrawMeshNowOrLater(mesh3, loc3, quaternion, material3, portrait); } } } } if (!flag && bodyDrawType != RotDrawMode.Dessicated && !headStump) { Mesh mesh4 = graphics.HairMeshSet.MeshAt(headFacing); Material mat = graphics.HairMatAt(headFacing); GenDraw.DrawMeshNowOrLater(mesh4, loc2, quaternion, mat, portrait); } } if (renderBody) { for (int k = 0; k < graphics.apparelGraphics.Count; k++) { ApparelGraphicRecord apparelGraphicRecord = graphics.apparelGraphics[k]; if (apparelGraphicRecord.sourceApparel.def.apparel.LastLayer == ApparelLayerDefOf.Shell) { Material material4 = apparelGraphicRecord.graphic.MatAt(bodyFacing, null); material4 = graphics.flasher.GetDamagedMat(material4); GenDraw.DrawMeshNowOrLater(mesh, vector, quaternion, material4, portrait); } } } if (!portrait && pawn.RaceProps.Animal && pawn.inventory != null && pawn.inventory.innerContainer.Count > 0 && graphics.packGraphic != null) { Graphics.DrawMesh(mesh, vector, quaternion, graphics.packGraphic.MatAt(bodyFacing, null), 0); } if (!portrait) { if (pawn.apparel != null) { List <Apparel> wornApparel = pawn.apparel.WornApparel; for (int l = 0; l < wornApparel.Count; l++) { wornApparel[l].DrawWornExtras(); } } Vector3 bodyLoc = rootLoc; bodyLoc.y += 0.04296875f; } }
protected void RenderSlot(TrackedColonist slot, Vector2 position) { if (Event.current.type != EventType.Repaint) { return; } Rot4 south = Rot4.South; Pawn pawn = slot.Pawn; PawnGraphicSet graphics = pawn.drawer.renderer.graphics; if (!graphics.AllResolved) { graphics.ResolveAllGraphics(); } bool flag = slot.Dead || slot.Missing; bool cryptosleep = slot.Cryptosleep; Quaternion identity = Quaternion.identity; Vector3 one = Vector3.one; Graphics.DrawMesh(this.backgroundMesh, Matrix4x4.TRS(new Vector3(position.x + ColonistBarDrawer.BackgroundOffset.x, position.y + ColonistBarDrawer.BackgroundOffset.y, 0f), identity, one), ColonistBarDrawer.SlotBackgroundMat, 1, this.camera, 0, null); MaterialPropertyBlock properties = null; if (flag) { properties = this.deadPropertyBlock; } else if (slot.Cryptosleep) { properties = this.cryptosleepPropertyBlock; } float num = 1f; Material material; foreach (Material current in graphics.MatsBodyBaseAt(south, RotDrawMode.Fresh)) { material = current; if (flag) { material = this.GetDeadMaterial(current); } else if (cryptosleep) { material = this.GetFrozenMaterial(current); } Graphics.DrawMesh(this.bodyMesh, Matrix4x4.TRS(new Vector3(position.x + ColonistBarDrawer.PortraitOffset.x, position.y + ColonistBarDrawer.PortraitOffset.y, num), identity, one), material, 1, this.camera, 0, properties); num += 1f; } Material material2; for (int i = 0; i < graphics.apparelGraphics.Count; i++) { ApparelGraphicRecord apparelGraphicRecord = graphics.apparelGraphics[i]; if (apparelGraphicRecord.sourceApparel.def.apparel.LastLayer == ApparelLayer.Shell) { material2 = apparelGraphicRecord.graphic.MatAt(south, null); material2 = graphics.flasher.GetDamagedMat(material2); material = material2; if (flag) { material = this.GetDeadMaterial(material2); } else if (cryptosleep) { material = this.GetFrozenMaterial(material2); } Graphics.DrawMesh(this.bodyMesh, Matrix4x4.TRS(new Vector3(position.x + ColonistBarDrawer.PortraitOffset.x, position.y + ColonistBarDrawer.PortraitOffset.y, num), identity, one), material, 1, this.camera, 0, properties); num += 1f; } } Graphics.DrawMesh(this.backgroundMesh, Matrix4x4.TRS(new Vector3(position.x + ColonistBarDrawer.BackgroundOffset.x, position.y + ColonistBarDrawer.BackgroundOffset.y, num), identity, one), ColonistBarDrawer.SlotBordersMat, 1, this.camera); num += 1f; if ((slot.Corpse != null) ? Find.Selector.IsSelected(slot.Corpse) : Find.Selector.IsSelected(pawn)) { Graphics.DrawMesh(this.backgroundMesh, Matrix4x4.TRS(new Vector3(position.x + ColonistBarDrawer.BackgroundOffset.x, position.y + ColonistBarDrawer.BackgroundOffset.y, num), identity, one), ColonistBarDrawer.SlotSelectedMat, 1, this.camera); num += 1f; } material2 = pawn.drawer.renderer.graphics.HeadMatAt(south, RotDrawMode.Fresh); material = material2; if (flag) { material = this.GetDeadMaterial(material2); } else if (cryptosleep) { material = this.GetFrozenMaterial(material2); } Graphics.DrawMesh(this.headMesh, Matrix4x4.TRS(new Vector3(position.x + ColonistBarDrawer.HeadOffset.x, position.y + ColonistBarDrawer.HeadOffset.y, num), identity, one), material, 1, this.camera, 0, properties); num += 1f; bool flag2 = false; List <ApparelGraphicRecord> apparelGraphics = graphics.apparelGraphics; for (int j = 0; j < apparelGraphics.Count; j++) { if (apparelGraphics[j].sourceApparel.def.apparel.LastLayer == ApparelLayer.Overhead) { flag2 = true; material2 = apparelGraphics[j].graphic.MatAt(south, null); material2 = graphics.flasher.GetDamagedMat(material2); material = material2; if (flag) { material = this.GetDeadMaterial(material2); } else if (cryptosleep) { material = this.GetFrozenMaterial(material2); } Graphics.DrawMesh(this.headMesh, Matrix4x4.TRS(new Vector3(position.x + ColonistBarDrawer.HeadOffset.x, position.y + ColonistBarDrawer.HeadOffset.y, num), identity, one), material, 1, this.camera, 0, properties); num += 1f; } } if (!flag2 && slot.Pawn.story.hairDef != null) { material2 = graphics.HairMatAt(south); material = material2; if (flag) { material = this.GetDeadMaterial(material2); } else if (cryptosleep) { material = this.GetFrozenMaterial(material2); } Graphics.DrawMesh(this.headMesh, Matrix4x4.TRS(new Vector3(position.x + ColonistBarDrawer.HeadOffset.x, position.y + ColonistBarDrawer.HeadOffset.y, num), identity, one), material, 1, this.camera, 0, properties); num += 1f; } }