//PawnGraphicSet.MatsBodyBaseAt public static bool Vamp_MatsBodyBaseAt(PawnGraphicSet __instance, Rot4 facing, RotDrawMode bodyCondition, bool drawClothes, ref List <Material> __result) { if (__instance.nakedGraphic != null) { return(true); } if (__instance.pawn.IsVampire() && __instance?.pawn?.VampComp()?.CurrentForm != null) { __instance.nakedGraphic = __instance.pawn.VampComp().CurrentForm.bodyGraphicData.Graphic; return(true); } __result = new List <Material>(); __result.Add(GraphicDatabase.Get <Graphic_Single>("NullTex").MatSingle); return(false); }
private void RenderPawnInternal(Vector3 rootLoc, Quaternion quat, bool renderBody, Rot4 bodyFacing, Rot4 headFacing, RotDrawMode bodyDrawType, bool portrait, bool headStump) { if (!this.graphics.AllResolved) { this.graphics.ResolveAllGraphics(); } Mesh mesh = null; if (renderBody) { Vector3 loc = rootLoc; loc.y += 0.0078125f; if (bodyDrawType == RotDrawMode.Dessicated && !this.pawn.RaceProps.Humanlike && this.graphics.dessicatedGraphic != null && !portrait) { this.graphics.dessicatedGraphic.Draw(loc, bodyFacing, this.pawn, 0f); } else { if (this.pawn.RaceProps.Humanlike) { mesh = MeshPool.humanlikeBodySet.MeshAt(bodyFacing); } else { mesh = this.graphics.nakedGraphic.MeshAt(bodyFacing); } List <Material> list = this.graphics.MatsBodyBaseAt(bodyFacing, bodyDrawType); for (int i = 0; i < list.Count; i++) { Material damagedMat = this.graphics.flasher.GetDamagedMat(list[i]); GenDraw.DrawMeshNowOrLater(mesh, loc, quat, damagedMat, portrait); loc.y += 0.00390625f; } if (bodyDrawType == RotDrawMode.Fresh) { Vector3 drawLoc = rootLoc; drawLoc.y += 0.01953125f; this.woundOverlays.RenderOverBody(drawLoc, mesh, quat, portrait); } } } 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 (this.graphics.headGraphic != null) { Vector3 b = quat * this.BaseHeadOffsetAt(headFacing); Material material = this.graphics.HeadMatAt(headFacing, bodyDrawType, headStump); if (material != null) { Mesh mesh2 = MeshPool.humanlikeHeadSet.MeshAt(headFacing); GenDraw.DrawMeshNowOrLater(mesh2, a + b, quat, material, portrait); } Vector3 loc2 = rootLoc + b; loc2.y += 0.03125f; bool flag = false; if (!portrait || !Prefs.HatsOnlyOnMap) { Mesh mesh3 = this.graphics.HairMeshSet.MeshAt(headFacing); List <ApparelGraphicRecord> apparelGraphics = this.graphics.apparelGraphics; for (int j = 0; j < apparelGraphics.Count; j++) { if (apparelGraphics[j].sourceApparel.def.apparel.LastLayer == ApparelLayer.Overhead) { if (!apparelGraphics[j].sourceApparel.def.apparel.hatRenderedFrontOfFace) { flag = true; Material material2 = apparelGraphics[j].graphic.MatAt(bodyFacing, null); material2 = this.graphics.flasher.GetDamagedMat(material2); GenDraw.DrawMeshNowOrLater(mesh3, loc2, quat, material2, portrait); } else { Material material3 = apparelGraphics[j].graphic.MatAt(bodyFacing, null); material3 = this.graphics.flasher.GetDamagedMat(material3); Vector3 loc3 = rootLoc + b; loc3.y += ((!(bodyFacing == Rot4.North)) ? 0.03515625f : 0.00390625f); GenDraw.DrawMeshNowOrLater(mesh3, loc3, quat, material3, portrait); } } } } if (!flag && bodyDrawType != RotDrawMode.Dessicated && !headStump) { Mesh mesh4 = this.graphics.HairMeshSet.MeshAt(headFacing); Material mat = this.graphics.HairMatAt(headFacing); GenDraw.DrawMeshNowOrLater(mesh4, loc2, quat, mat, 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 == ApparelLayer.Shell) { Material material4 = apparelGraphicRecord.graphic.MatAt(bodyFacing, null); material4 = this.graphics.flasher.GetDamagedMat(material4); GenDraw.DrawMeshNowOrLater(mesh, vector, quat, 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, quat, this.graphics.packGraphic.MatAt(bodyFacing, null), 0); } if (!portrait) { this.DrawEquipment(rootLoc); 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.04296875f; this.statusOverlays.RenderStatusOverlays(bodyLoc, quat, MeshPool.humanlikeHeadSet.MeshAt(headFacing)); } }
private static void Postfix(PawnRenderer __instance, ref Vector3 rootLoc, ref float angle, ref bool renderBody, ref Rot4 bodyFacing, ref Rot4 headFacing, ref RotDrawMode bodyDrawType, ref bool portrait, ref bool headStump, ref bool invisible, Pawn ___pawn) { if (invisible) { return; } if (__instance != null) { Pawn pawn = ___pawn; var hediff = (AlienMutationHediff)pawn.health.hediffSet.GetFirstHediffOfDef(PurpleIvyDefOf.PI_AlienMutation); if (pawn != null && !pawn.Dead && hediff != null && hediff.mutationActive && !headStump && ((!portrait && pawn?.jobs?.curDriver != null ? !pawn.jobs.curDriver.asleep : portrait) || portrait)) { Quaternion quat = Quaternion.AngleAxis(angle, Vector3.up); //Get base offset. Vector3 baseHeadOffset = rootLoc; if (bodyFacing != Rot4.North) { baseHeadOffset.y += 0.0281250011f; rootLoc.y += 0.0234375f; } else { baseHeadOffset.y += 0.0234375f; rootLoc.y += 0.0281250011f; } Vector3 headOffset = quat * __instance.BaseHeadOffsetAt(headFacing); //Finalize offset. Vector3 eyeOffset = baseHeadOffset + headOffset + new Vector3(0f, 0.01f, 0f); //Render eyes. if (headFacing != Rot4.North) { //Is not the back. Mesh headMesh = MeshPool.humanlikeHeadSet.MeshAt(headFacing); Log.Message("Glow eyes"); if (headFacing.IsHorizontal) { //Side GenDraw.DrawMeshNowOrLater(headMesh, eyeOffset, quat, PurpleEyes.GetEyeGraphic(false, new Color(0.368f, 0f, 1f)).MatSingle, portrait); } else { //Front GenDraw.DrawMeshNowOrLater(headMesh, eyeOffset, quat, PurpleEyes.GetEyeGraphic(true, new Color(0.368f, 0f, 1f)).MatSingle, portrait); } } } } }
public override void DrawBody( PawnWoundDrawer woundDrawer, Vector3 rootLoc, Quaternion quat, RotDrawMode bodyDrawType, bool renderBody, bool portrait) { // renderBody is AFAIK only used for beds, so ignore it and undress if (renderBody || Controller.settings.IgnoreRenderBody) { Vector3 bodyLoc = rootLoc; bodyLoc.x += this.CompAnimator.BodyAnim?.offCenterX ?? 0f; bodyLoc.y += Offsets.YOffset_Body; if (bodyDrawType == RotDrawMode.Dessicated && !this.Pawn.RaceProps.Humanlike && this.Pawn.Drawer.renderer.graphics.dessicatedGraphic != null && !portrait) { this.Pawn.Drawer.renderer.graphics.dessicatedGraphic.Draw(bodyLoc, this.BodyFacing, this.Pawn); } else { Mesh bodyMesh; if (this.Pawn.RaceProps.Humanlike) { bodyMesh = this.GetPawnMesh(true, portrait); } else { bodyMesh = this.Pawn.Drawer.renderer.graphics.nakedGraphic.MeshAt(this.BodyFacing); } List <Material> bodyBaseAt = null; bool flag = true; if (!portrait && Controller.settings.HideShellWhileRoofed) { if (this.CompAnimator.InRoom) { MaxLayerToShow layer; if (this.CompAnimator.InPrivateRoom) { layer = renderBody ? Controller.settings.LayerInPrivateRoom : Controller.settings.LayerInOwnedBed; } else { layer = renderBody ? Controller.settings.LayerInRoom : Controller.settings.LayerInBed; } bodyBaseAt = this.BodyBaseAt(this.Graphics, this.BodyFacing, bodyDrawType, layer); flag = false; } } if (flag) { bodyBaseAt = this.Graphics.MatsBodyBaseAt(this.BodyFacing, bodyDrawType); } foreach (Material material in bodyBaseAt) { Material damagedMat = this.Graphics.flasher.GetDamagedMat(material); GenDraw.DrawMeshNowOrLater(bodyMesh, bodyLoc, quat, damagedMat, portrait); bodyLoc.y += Offsets.YOffsetInterval_Clothes; } if (bodyDrawType == RotDrawMode.Fresh) { Vector3 drawLoc = rootLoc; drawLoc.y += Offsets.YOffset_Wounds; woundDrawer?.RenderOverBody(drawLoc, bodyMesh, quat, portrait); } } } }
private static void RenderFacepaint(PawnRenderer instance, bool hideFacepaint, RotDrawMode bodyDrawType, bool headStump, Rot4 headFacing, Vector3 baseDrawPos, Quaternion quaternion, bool portrait) { var pawn = instance.graphics.pawn; if (bodyDrawType != RotDrawMode.Dessicated && !headStump && pawn.GetComp <CompFacepaint>() is CompFacepaint facepaintComp) { Mesh mesh = instance.graphics.HairMeshSet.MeshAt(headFacing); if (facepaintComp.facepaintGraphicOne != null) { GenDraw.DrawMeshNowOrLater(mesh, baseDrawPos - new Vector3(0, 0.0007f, 0), quaternion, facepaintComp.facepaintGraphicOne.MatAt(headFacing), portrait); } if (facepaintComp.facepaintGraphicTwo != null) { GenDraw.DrawMeshNowOrLater(mesh, baseDrawPos - new Vector3(0, 0.0005f, 0), quaternion, facepaintComp.facepaintGraphicTwo.MatAt(headFacing), portrait); } } }
public void RenderPawnAt(Vector3 drawLoc, RotDrawMode bodyDrawType, bool headStump, bool invisible , int curLevel, int baseLevel) { if (!this.graphics.AllResolved) { this.graphics.ResolveAllGraphics(); } if (this.pawn.GetPosture() == PawnPosture.Standing) { this.RenderPawnInternal(drawLoc, 0f, true, bodyDrawType, headStump, invisible, curLevel, baseLevel); if (this.pawn.carryTracker != null) { Thing carriedThing = this.pawn.carryTracker.CarriedThing; if (carriedThing != null) { Vector3 vector = drawLoc; bool flag = false; bool flip = false; if (this.pawn.CurJob == null || !this.pawn.jobs.curDriver.ModifyCarriedThingDrawPos(ref vector, ref flag, ref flip)) { if (carriedThing is Pawn || carriedThing is Corpse) { vector += new Vector3(0.44f, 0f, 0f); } else { vector += new Vector3(0.18f, 0f, 0.05f); } } if (flag) { vector.y -= 0.03787879f; } else { vector.y += 0.03787879f; } carriedThing.DrawAt(vector, flip); } } if (!invisible) { if (this.pawn.def.race.specialShadowData != null) { if (this.shadowGraphic == null) { this.shadowGraphic = new Graphic_Shadow(this.pawn.def.race.specialShadowData); } this.shadowGraphic.Draw(drawLoc, Rot4.North, this.pawn, 0f); } if (this.graphics.nakedGraphic != null && this.graphics.nakedGraphic.ShadowGraphic != null) { this.graphics.nakedGraphic.ShadowGraphic.Draw(drawLoc, Rot4.North, this.pawn, 0f); } } } else { float angle = this.BodyAngle(); Rot4 rot = this.LayingFacing(); Building_Bed building_Bed = this.pawn.CurrentBed(); bool renderBody; Vector3 rootLoc; if (building_Bed != null && this.pawn.RaceProps.Humanlike) { renderBody = building_Bed.def.building.bed_showSleeperBody; AltitudeLayer altLayer = (AltitudeLayer)Mathf.Max((int)building_Bed.def.altitudeLayer, 16); Vector3 vector2; Vector3 a = vector2 = this.pawn.Position.ToVector3ShiftedWithAltitude(altLayer); vector2.y += 0.0265151523f; Rot4 rotation = building_Bed.Rotation; rotation.AsInt += 2; float d = -this.BaseHeadOffsetAt(Rot4.South).z; Vector3 a2 = rotation.FacingCell.ToVector3(); rootLoc = a + a2 * d; rootLoc.y += 0.007575758f; } else { renderBody = true; rootLoc = drawLoc; if (!this.pawn.Dead && this.pawn.CarriedBy == null) { rootLoc.y = AltitudeLayer.LayingPawn.AltitudeFor() + 0.007575758f; } } this.RenderPawnInternal(rootLoc, angle, renderBody, rot, rot, bodyDrawType, false, headStump, invisible, curLevel, baseLevel); } if (this.pawn.Spawned && !this.pawn.Dead) { this.pawn.stances.StanceTrackerDraw(); this.pawn.pather.PatherDraw(); } }
static void DrawImplant(HediffComp_DrawImplant comp, PawnRenderer __instance, Vector3 rootLoc, float angle, bool renderBody, Rot4 bodyFacing, Rot4 headFacing, RotDrawMode bodyDrawType, bool portrait, bool headStump) {// this.Pawn Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); bool selected = Find.Selector.SelectedObjects.Contains(pawn) && Prefs.DevMode; Rot4 rot = bodyFacing; Vector3 vector3 = pawn.RaceProps.Humanlike ? __instance.BaseHeadOffsetAt(headFacing) : new Vector3(); Vector3 s = new Vector3(pawn.BodySize * 1.75f, pawn.BodySize * 1.75f, pawn.BodySize * 1.75f); GetAltitudeOffset(pawn, comp.parent, rot, out float X, out float Y, out float Z, out float DsX, out float DsZ, out float ang); vector3.x += X; vector3.y += Y; vector3.z += Z; angle += ang; s.x = DsX; s.z = DsZ; if (pawn.RaceProps.Humanlike) { vector3.x += 0.01f; vector3.z += -0.35f; } Quaternion quaternion = Quaternion.AngleAxis(angle, Vector3.up); Vector3 b = quaternion * vector3; 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; } /* * Material material = __instance.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.03105f; bool flag = false; /* * if (!portrait || !Prefs.HatsOnlyOnMap) * { * Mesh mesh3 = __instance.graphics.HairMeshSet.MeshAt(headFacing); * List<ApparelGraphicRecord> apparelGraphics = __instance.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 = __instance.graphics.flasher.GetDamagedMat(material2); * GenDraw.DrawMeshNowOrLater(mesh3, loc2, quaternion, material2, portrait); * } * else * { * Material material3 = apparelGraphics[j].graphic.MatAt(bodyFacing, null); * material3 = __instance.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) { #if DEBUG if (selected) { // Log.Message(string.Format("{0}'s rootLoc: {1}, angle: {2}, renderBody: {3}, bodyFacing: {4}, headFacing: {5}, bodyDrawType: {6}, portrait: {7}", pawn.Label, rootLoc, angle, renderBody, bodyFacing.ToStringHuman(), headFacing.ToStringHuman(), bodyDrawType, portrait)); } #endif if (!portrait) { // Mesh mesh4 = __instance.graphics.HairMeshSet.MeshAt(headFacing); Material mat = comp.ImplantMaterial(pawn, pawn.RaceProps.Humanlike ? headFacing : bodyFacing); // GenDraw.DrawMeshNowOrLater(headFacing == Rot4.West ? MeshPool.plane10Flip : MeshPool.plane10, loc2, quaternion, mat, true); Matrix4x4 matrix = default(Matrix4x4); matrix.SetTRS(loc2, quaternion, s); Graphics.DrawMesh((pawn.RaceProps.Humanlike ? headFacing : bodyFacing) == Rot4.West ? MeshPool.plane10Flip : MeshPool.plane10, matrix, mat, 0); // Graphics.DrawMesh((pawn.RaceProps.Humanlike ? headFacing : bodyFacing) == Rot4.West ? MeshPool.plane10Flip : MeshPool.plane10, matrix, mat, 0); } } /* * Material matSingle = comp.ImplantMaterial(pawn, rot); * Matrix4x4 matrix = default(Matrix4x4); * matrix.SetTRS(drawPos, Quaternion.AngleAxis(angle, Vector3.up), s); * Graphics.DrawMesh(rot == Rot4.West ? MeshPool.plane10Flip : MeshPool.plane10, matrix, matSingle, 0); */ }
private void RenderPawnInternal(Vector3 rootLoc, float angle, bool renderBody, RotDrawMode draw, bool headStump) { RenderPawnInternal(rootLoc, angle, renderBody, pawn.Rotation, pawn.Rotation, draw, portrait: false, headStump); }
public void RenderPawnAt(Vector3 drawLoc, RotDrawMode bodyDrawType, bool headStump) { if (!graphics.AllResolved) { graphics.ResolveAllGraphics(); } if (pawn.GetPosture() == PawnPosture.Standing) { RenderPawnInternal(drawLoc, 0f, renderBody: true, bodyDrawType, headStump); if (pawn.carryTracker != null) { Thing carriedThing = pawn.carryTracker.CarriedThing; if (carriedThing != null) { Vector3 drawPos = drawLoc; bool behind = false; bool flip = false; if (pawn.CurJob == null || !pawn.jobs.curDriver.ModifyCarriedThingDrawPos(ref drawPos, ref behind, ref flip)) { drawPos = ((!(carriedThing is Pawn) && !(carriedThing is Corpse)) ? (drawPos + new Vector3(0.18f, 0f, 0.05f)) : (drawPos + new Vector3(0.44f, 0f, 0f))); } if (behind) { drawPos.y -= 0.0390625f; } else { drawPos.y += 0.0390625f; } carriedThing.DrawAt(drawPos, flip); } } if (pawn.def.race.specialShadowData != null) { if (shadowGraphic == null) { shadowGraphic = new Graphic_Shadow(pawn.def.race.specialShadowData); } shadowGraphic.Draw(drawLoc, Rot4.North, pawn); } if (graphics.nakedGraphic != null && graphics.nakedGraphic.ShadowGraphic != null) { graphics.nakedGraphic.ShadowGraphic.Draw(drawLoc, Rot4.North, pawn); } } else { Rot4 rot = LayingFacing(); Building_Bed building_Bed = pawn.CurrentBed(); bool renderBody; float angle; Vector3 rootLoc; if (building_Bed != null && pawn.RaceProps.Humanlike) { renderBody = building_Bed.def.building.bed_showSleeperBody; Rot4 rotation = building_Bed.Rotation; rotation.AsInt += 2; angle = rotation.AsAngle; AltitudeLayer altLayer = (AltitudeLayer)Mathf.Max((int)building_Bed.def.altitudeLayer, 15); Vector3 vector = pawn.Position.ToVector3ShiftedWithAltitude(altLayer); Vector3 vector2 = vector; vector2.y += 0.02734375f; Vector3 vector3 = BaseHeadOffsetAt(Rot4.South); float d = 0f - vector3.z; Vector3 a = rotation.FacingCell.ToVector3(); rootLoc = vector + a * d; rootLoc.y += 0.0078125f; } else { renderBody = true; rootLoc = drawLoc; if (!pawn.Dead && pawn.CarriedBy == null) { rootLoc.y = AltitudeLayer.LayingPawn.AltitudeFor() + 0.0078125f; } if (pawn.Downed || pawn.Dead) { angle = wiggler.downedAngle; } else if (pawn.RaceProps.Humanlike) { angle = rot.AsAngle; } else { Rot4 rot2 = Rot4.West; switch (pawn.thingIDNumber % 2) { case 0: rot2 = Rot4.West; break; case 1: rot2 = Rot4.East; break; } angle = rot2.AsAngle; } } RenderPawnInternal(rootLoc, angle, renderBody, rot, rot, bodyDrawType, portrait: false, headStump); } if (pawn.Spawned && !pawn.Dead) { pawn.stances.StanceTrackerDraw(); pawn.pather.PatherDraw(); } DrawDebug(); }
public static void Patch_PawnRenderer_RenderPawnAt(PawnRenderer __instance, ref Vector3 drawLoc, ref RotDrawMode bodyDrawType, ref bool headStump) { Pawn pawn = PawnRenderer_GetPawn(__instance); //Render shield. if (pawn != null && pawn.GetShield() is ThingWithComps shield) { Vector3 bodyVector = drawLoc; CompShield shieldComp = shield.GetComp <CompShield>(); bodyVector += shieldComp.ShieldProps.renderProperties.Rot4ToVector3(pawn.Rotation); shieldComp.RenderShield(bodyVector, pawn.Rotation, pawn, shield); } }
public static bool Prefix(PawnRenderer __instance, ref Vector3 rootLoc, Quaternion quat, bool renderBody, Rot4 bodyFacing, Rot4 headFacing, RotDrawMode bodyDrawType, bool portrait, bool headStump) { // Pawn pawn = (Pawn)PawnFieldInfo?.GetValue(__instance); PawnGraphicSet graphics = __instance.graphics; Pawn pawn = graphics.pawn; if (!pawn.RaceProps.Humanlike && !Controller.settings.UsePaws) { return(true); } if (!graphics.AllResolved) { graphics.ResolveAllGraphics(); } CompFace compFace = pawn.GetCompFace(); bool hasFace = compFace != null; // Let vanilla do the job if no FacePawn or pawn not a teenager or any other known mod accessing the renderer if (hasFace) { if (compFace.IsChild || compFace.Deactivated) { return(true); } } CompBodyAnimator compAnim = pawn.GetCompAnim(); bool showFeet = compAnim != null && Controller.settings.UseFeet; // No face, no animator, return if (!hasFace && compAnim == null) { return(true); } PawnWoundDrawer woundDrawer = (PawnWoundDrawer)WoundOverlayFieldInfo?.GetValue(__instance); // if (Patches2.Plants) // { // if (pawn.Spawned) // { // Plant plant = (pawn.Position + IntVec3.South).GetPlant(pawn.Map); // if (plant != null && Patches2.plantMoved.Contains(plant)) // { // rootLoc.y = plant.DrawPos.y - (Patches2.steps / 2); // } // } // } // Try to move the y position behind while another pawn is standing near if (compAnim != null && (!portrait && pawn.Spawned && !compAnim.IsRider)) { RecalcRootLocY(ref rootLoc, pawn, compAnim); } Vector3 baseDrawLoc = rootLoc; // Let's save the basic location for later Vector3 footPos = baseDrawLoc; // No face => must be animal, simplify it Quaternion bodyQuat = quat; Quaternion footQuat = bodyQuat; if (MainTabWindow_WalkAnimator.IsOpen) { bodyFacing = MainTabWindow_BaseAnimator.BodyRot; headFacing = MainTabWindow_BaseAnimator.HeadRot; } compFace?.TickDrawers(bodyFacing, headFacing, graphics); compAnim?.TickDrawers(bodyFacing, graphics); // Use the basic quat Quaternion headQuat = bodyQuat; // Rotate head if possible and wobble around if (!portrait || MainTabWindow_WalkAnimator.IsOpen) { if (showFeet) { compAnim.ApplyBodyWobble(ref baseDrawLoc, ref footPos, ref bodyQuat); } // Reset the quat as it has been changed headQuat = bodyQuat; compFace?.ApplyHeadRotation(renderBody, ref headQuat); } // Regular FacePawn rendering 14+ years // Render body // if (renderBody) compAnim?.DrawBody(baseDrawLoc, bodyQuat, bodyDrawType, woundDrawer, renderBody, portrait); Vector3 bodyPos = baseDrawLoc; Vector3 headPos = baseDrawLoc; if (bodyFacing == Rot4.North) { headPos.y += YOffset_Shell; bodyPos.y += YOffset_Head; } else { headPos.y += YOffset_Head; bodyPos.y += YOffset_Shell; } if (graphics.headGraphic != null) { // Rendererd pawn faces Vector3 offsetAt = !hasFace ? __instance.BaseHeadOffsetAt(bodyFacing) : compFace.BaseHeadOffsetAt(portrait); Vector3 b = bodyQuat * offsetAt; Vector3 headDrawLoc = headPos + b; if (!hasFace) { Material material = graphics.HeadMatAt(headFacing, bodyDrawType, headStump); if (material != null) { Mesh mesh2 = MeshPool.humanlikeHeadSet.MeshAt(headFacing); GenDraw.DrawMeshNowOrLater(mesh2, headDrawLoc, quat, material, portrait); } } else { compFace.DrawBasicHead(out bool headDrawn, bodyDrawType, portrait, headStump, headDrawLoc, headQuat); if (headDrawn) { if (bodyDrawType != RotDrawMode.Dessicated && !headStump) { if (compFace.Props.hasWrinkles) { Vector3 wrinkleLoc = headDrawLoc; wrinkleLoc.y += YOffset_Wrinkles; compFace.DrawWrinkles(bodyDrawType, wrinkleLoc, headQuat, portrait); } if (compFace.Props.hasEyes) { Vector3 eyeLoc = headDrawLoc; eyeLoc.y += YOffset_Eyes; compFace.DrawNaturalEyes(eyeLoc, portrait, headQuat); Vector3 browLoc = headDrawLoc; browLoc.y += YOffset_Brows; // the brow above compFace.DrawBrows(browLoc, headQuat, portrait); // and now the added eye parts Vector3 unnaturalEyeLoc = headDrawLoc; unnaturalEyeLoc.y += YOffset_UnnaturalEyes; compFace.DrawUnnaturalEyeParts(unnaturalEyeLoc, headQuat, portrait); } // Portrait obviously ignores the y offset, thus render the beard after the body apparel (again) if (compFace.Props.hasBeard) { Vector3 beardLoc = headDrawLoc; Vector3 tacheLoc = headDrawLoc; beardLoc.y += headFacing == Rot4.North ? -YOffset_Head : YOffset_Beard; tacheLoc.y += (((headFacing == Rot4.North)) ? -YOffset_Head : YOffset_Tache); compFace.DrawBeardAndTache(beardLoc, tacheLoc, portrait, headQuat); } if (compFace.Props.hasMouth) { Vector3 mouthLoc = headDrawLoc; mouthLoc.y += YOffset_Mouth; compFace.DrawNaturalMouth(mouthLoc, portrait, headQuat); } // Deactivated, looks kinda crappy ATM // if (pawn.Dead) // { // Material deadEyeMat = faceComp.DeadEyeMatAt(headFacing, bodyDrawType); // if (deadEyeMat != null) // { // GenDraw.DrawMeshNowOrLater(mesh2, locFacialY, headQuat, deadEyeMat, portrait); // locFacialY.y += YOffsetInterval_OnFace; // } // } // else } } } if (!headStump) { Vector3 overHead = baseDrawLoc + b; overHead.y += YOffset_OnHead; Vector3 hairLoc = overHead; Vector3 headgearLoc = overHead; Vector3 hatInFrontOfFace = baseDrawLoc + b; hairLoc.y += YOffset_HairOnHead; headgearLoc.y += YOffset_GearOnHead; hatInFrontOfFace.y += ((!(headFacing == Rot4.North)) ? YOffset_PostHead : YOffset_Behind); compFace?.DrawHairAndHeadGear(hairLoc, headgearLoc, bodyDrawType, portrait, renderBody, headQuat, hatInFrontOfFace); compFace?.DrawAlienHeadAddons(headPos, portrait, headQuat, overHead); } } if (!portrait) { // Traverse.Create(__instance).Method("DrawEquipment", rootLoc).GetValue(); DrawEquipmentMethodInfo?.Invoke(__instance, new object[] { baseDrawLoc }); } if (!portrait) { if (pawn.apparel != null) { List <Apparel> wornApparel = pawn.apparel.WornApparel; foreach (Apparel ap in wornApparel) { DrawPos_Patch.offset = baseDrawLoc; DrawPos_Patch.offsetEnabled = true; ap.DrawWornExtras(); DrawPos_Patch.offsetEnabled = false; } } Vector3 bodyLoc = baseDrawLoc; bodyLoc.y += YOffset_Status; PawnHeadOverlays headOverlays = (PawnHeadOverlays)PawnHeadOverlaysFieldInfo?.GetValue(__instance); if (headOverlays != null) { compFace?.DrawHeadOverlays(headOverlays, bodyLoc, headQuat); } } compAnim?.DrawApparel(bodyQuat, bodyPos, portrait, renderBody); compAnim?.DrawAlienBodyAddons(bodyQuat, bodyPos, portrait, renderBody, bodyFacing); if (!portrait && pawn.RaceProps.Animal && pawn.inventory != null && pawn.inventory.innerContainer.Count > 0 && graphics.packGraphic != null) { Mesh mesh = graphics.nakedGraphic.MeshAt(bodyFacing); Graphics.DrawMesh(mesh, bodyPos, quat, graphics.packGraphic.MatAt(bodyFacing), 0); } // No wobble for equipment, looks funnier - nah! // Vector3 equipPos = rootLoc; // equipPos.y = drawPos.y; //compAnim.DrawEquipment(drawPos, portrait); bool showHands = Controller.settings.UseHands; Vector3 handPos = bodyPos; if (renderBody || Controller.settings.IgnoreRenderBody) { if (showHands) { // Reset the position for the hands handPos.y = baseDrawLoc.y; compAnim?.DrawHands(bodyQuat, handPos, portrait); } if (showFeet) { compAnim.DrawFeet(bodyQuat, footQuat, footPos, portrait); } } return(false); }
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); } } } } }
private static void RenderPawnInternal(PawnRenderer __instance, Vector3 rootLoc, Quaternion quat, bool renderBody, Rot4 bodyFacing, Rot4 headFacing, RotDrawMode bodyDrawType = RotDrawMode.Fresh, bool portrait = false) { Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); if (!pawn.def.race.Humanlike) { return; } Corruption.CompPsyker compPsyker = pawn.TryGetComp <CompPsyker>(); List <HediffComp_DrawImplant> implantDrawers = HarmonyPatches.implantDrawers(pawn); string patronName = "Emperor"; bool drawChaos = false; if (compPsyker != null) { patronName = compPsyker.patronName; // Log.Message("GettingComp: " + patronName); if (patronName == "Khorne" || patronName == "Nurgle" || patronName == "Tzeentch" || patronName == "Undivided") { // Log.Message("drawChaos"); drawChaos = true; } } if (!__instance.graphics.AllResolved) { __instance.graphics.ResolveAllGraphics(); } Mesh mesh = null; if (renderBody) { Vector3 loc = rootLoc; loc.y += 0.005f; if (bodyDrawType == RotDrawMode.Dessicated && !pawn.RaceProps.Humanlike && __instance.graphics.dessicatedGraphic != null && !portrait) { __instance.graphics.dessicatedGraphic.Draw(loc, bodyFacing, pawn); } else { ThingDef_AlienRace alienDef = pawn.def as ThingDef_AlienRace; if (alienDef != null) { Mesh mesh2; if (bodyDrawType == RotDrawMode.Rotting) { if (__instance.graphics.dessicatedGraphic.ShouldDrawRotated) { mesh2 = MeshPool.GridPlane(portrait ? alienDef.alienRace.generalSettings.alienPartGenerator.CustomPortraitDrawSize : alienDef.alienRace.generalSettings.alienPartGenerator.CustomDrawSize); } else { Vector2 size = portrait ? alienDef.alienRace.generalSettings.alienPartGenerator.CustomPortraitDrawSize : alienDef.alienRace.generalSettings.alienPartGenerator.CustomDrawSize; if (bodyFacing.IsHorizontal) { size = size.Rotated(); } if (bodyFacing == Rot4.West && (__instance.graphics.dessicatedGraphic.data == null || __instance.graphics.dessicatedGraphic.data.allowFlip)) { mesh = MeshPool.GridPlaneFlip(size); } mesh = MeshPool.GridPlane(size); } } else { mesh = (portrait ? alienDef.alienRace.generalSettings.alienPartGenerator.bodyPortraitSet.MeshAt(bodyFacing) : alienDef.alienRace.generalSettings.alienPartGenerator.bodySet.MeshAt(bodyFacing)); } } else { if (pawn.RaceProps.Humanlike) { mesh = MeshPool.humanlikeBodySet.MeshAt(bodyFacing); } else { mesh = __instance.graphics.nakedGraphic.MeshAt(bodyFacing); } } List <Material> list = __instance.graphics.MatsBodyBaseAt(bodyFacing, bodyDrawType); for (int i = 0; i < list.Count; i++) { // Material damagedMat = __instance.graphics.flasher.GetDamagedMat(list[i]); // GenDraw.DrawMeshNowOrLater(mesh, loc, quat, damagedMat, portrait); loc.y += 0.005f; if (i == 0) { if (drawChaos) { Material markMat = (Corruption.AfflictionDrawerUtility.GetBodyOverlay(pawn.story.bodyType, patronName).MatAt(bodyFacing)); if (pawn.ageTracker.CurLifeStageIndex == 2 && pawn.RaceProps.Humanlike) { markMat.mainTextureScale = new Vector2(1, 1.3f); markMat.mainTextureOffset = new Vector2(0, -0.2f); if (bodyFacing == Rot4.West || bodyFacing == Rot4.East) { markMat.mainTextureOffset = new Vector2(-0.015f, -0.2f); } } GenDraw.DrawMeshNowOrLater(mesh, loc, quat, markMat, portrait); loc.y += 0.005f; } } if (bodyDrawType == RotDrawMode.Fresh) { Vector3 drawLoc = rootLoc; drawLoc.y += 0.02f; // Traverse.Create(__instance).Field("woundOverlays").GetValue<PawnWoundDrawer>().RenderOverBody(drawLoc, mesh, quat, portrait); } } } Vector3 vector = rootLoc; Vector3 a = rootLoc; if (bodyFacing != Rot4.North) { a.y += 0.03f; vector.y += 0.0249999985f; } else { a.y += 0.0249999985f; vector.y += 0.03f; } if (__instance.graphics.headGraphic != null) { Vector3 b = quat * __instance.BaseHeadOffsetAt(headFacing); Mesh mesh2 = MeshPool.humanlikeHeadSet.MeshAt(headFacing); Material mat = __instance.graphics.HeadMatAt(headFacing, bodyDrawType); // GenDraw.DrawMeshNowOrLater(mesh2, a + b, quat, mat, portrait); if (drawChaos) { Material headMarkMat = (AfflictionDrawerUtility.GetHeadGraphic(pawn, patronName).MatAt(bodyFacing)); // vector.y += 0.005f; GenDraw.DrawMeshNowOrLater(mesh2, a + b + new Vector3(0f, 0.004f, 0f), quat, headMarkMat, portrait); } Vector3 loc2 = rootLoc + b; loc2.y += 0.035f; bool flag = false; Mesh mesh3 = __instance.graphics.HairMeshSet.MeshAt(headFacing); List <ApparelGraphicRecord> apparelGraphics = __instance.graphics.apparelGraphics; for (int j = 0; j < apparelGraphics.Count; j++) { if (apparelGraphics[j].sourceApparel.def.apparel.LastLayer == ApparelLayer.Overhead) { flag = true; Material material = apparelGraphics[j].graphic.MatAt(bodyFacing, null); material = __instance.graphics.flasher.GetDamagedMat(material); // GenDraw.DrawMeshNowOrLater(mesh3, loc2, quat, material, portrait); } if (!flag && bodyDrawType != RotDrawMode.Dessicated) { Mesh mesh4 = __instance.graphics.HairMeshSet.MeshAt(headFacing); Material mat2 = __instance.graphics.HairMatAt(headFacing); // GenDraw.DrawMeshNowOrLater(mesh4, loc2, quat, mat2, portrait); } } if (renderBody) { for (int k = 0; k < __instance.graphics.apparelGraphics.Count; k++) { Material pauldronMat; if (CompPauldronDrawer.ShouldDrawPauldron(pawn, __instance.graphics.apparelGraphics[k].sourceApparel, bodyFacing, out pauldronMat)) { if (pawn.ageTracker.CurLifeStageIndex == 2) { pauldronMat.mainTextureScale = new Vector2(1.00f, 1.22f); pauldronMat.mainTextureOffset = new Vector2(0, -0.1f); } vector.y += 0.035f; GenDraw.DrawMeshNowOrLater(mesh, vector, quat, pauldronMat, portrait); } ApparelGraphicRecord apparelGraphicRecord = __instance.graphics.apparelGraphics[k]; if (apparelGraphicRecord.sourceApparel.def.apparel.LastLayer == ApparelLayer.Shell) { // Material material2 = apparelGraphicRecord.graphic.MatAt(bodyFacing, null); // material2 = __instance.graphics.flasher.GetDamagedMat(material2); // GenDraw.DrawMeshNowOrLater(mesh, vector, quat, material2, portrait); } if (!pawn.Dead) { for (int l = 0; l < pawn.health.hediffSet.hediffs.Count; l++) { HediffComp_DrawImplant drawer; if ((drawer = pawn.health.hediffSet.hediffs[l].TryGetComp <HediffComp_DrawImplant>()) != null) { if (drawer.implantDrawProps.implantDrawerType != ImplantDrawerType.Head) { vector.y += 0.005f; if (bodyFacing == Rot4.South && drawer.implantDrawProps.implantDrawerType == ImplantDrawerType.Backpack) { vector.y -= 0.3f; } Material implantMat = drawer.ImplantMaterial(pawn, bodyFacing); GenDraw.DrawMeshNowOrLater(mesh, vector, quat, implantMat, portrait); vector.y += 0.005f; } } } } } } } } }
public static bool RenderVampire(PawnRenderer __instance, Vector3 rootLoc, float angle, bool renderBody, Rot4 bodyFacing, RotDrawMode bodyDrawType, PawnRenderFlags flags) { Quaternion quat = Quaternion.AngleAxis(angle, Vector3.up); Pawn p = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); if (p?.Map?.GetComponent <MapComponent_HiddenTracker>()?.hiddenCharacters?.Contains(p) ?? false) { //<texPath>Things/Pawn/Animal/Tenebrous/tenebrous</texPath> //<drawSize>2.0</drawSize> if (VampireGraphicUtility.invisibleForm == null) { var graphicData = new GraphicData(); graphicData.drawSize = new Vector2(2, 2); graphicData.texPath = "Things/Pawn/Hidden/hidden"; VampireGraphicUtility.invisibleForm = graphicData.Graphic; } __instance.graphics.nakedGraphic = VampireGraphicUtility.invisibleForm; return(false); } if (p?.Map?.GetComponent <MapComponent_HiddenTracker>()?.toRemoveCharacters?.Contains(p) ?? false) { __instance.graphics.nakedGraphic = null; if (p.IsVampire() && p.VampComp() is CompVampire vampCompy) { vampCompy.atDirty = true; } p?.Map?.GetComponent <MapComponent_HiddenTracker>()?.toRemoveCharacters.Remove(p); //return false; } if (p?.VampComp() is CompVampire v) { if (v.Transformed) { if (__instance.graphics.nakedGraphic == null || v.CurFormGraphic == null || v.atDirty) { if (v.CurrentForm != null) { if (v.CurrentForm.GetCompProperties <CompAnimated.CompProperties_Animated>() is CompAnimated.CompProperties_Animated Props) { Graphic curGraphic = v.CurFormGraphic; v.CurFormGraphic = CompAnimated.CompAnimated.ResolveCurGraphic(p, Props, ref curGraphic, ref v.atCurIndex, ref v.atCurTicks, ref v.atDirty, false); } else { v.CurFormGraphic = v.CurrentForm.bodyGraphicData.Graphic; } } else { v.CurFormGraphic = p.kindDef.lifeStages[p.ageTracker.CurLifeStageIndex].bodyGraphicData.Graphic;// v.CurrentForm.lifeStages[0].bodyGraphicData.Graphic; } __instance.graphics.nakedGraphic = v.CurFormGraphic; __instance.graphics.ResolveApparelGraphics(); } Mesh mesh = null; if (renderBody) { Vector3 loc = rootLoc; loc.y += 0.0046875f; if (bodyDrawType == RotDrawMode.Dessicated && !p.RaceProps.Humanlike && __instance.graphics.dessicatedGraphic != null && !flags.HasFlag(PawnRenderFlags.Portrait)) { __instance.graphics.dessicatedGraphic.Draw(loc, bodyFacing, p); } else { mesh = __instance.graphics.nakedGraphic.MeshAt(bodyFacing); List <Material> list = __instance.graphics.MatsBodyBaseAt(bodyFacing, bodyDrawType); for (int i = 0; i < list.Count; i++) { Material damagedMat = __instance.graphics.flasher.GetDamagedMat(list[i]); Vector3 scaleVector = new Vector3(loc.x, loc.y, loc.z); if (flags.HasFlag(PawnRenderFlags.Portrait)) { scaleVector.x *= 1f + (1f - (flags.HasFlag(PawnRenderFlags.Portrait) ? v.CurrentForm.bodyGraphicData.drawSize : v.CurrentForm.bodyGraphicData.drawSize) .x); scaleVector.z *= 1f + (1f - (flags.HasFlag(PawnRenderFlags.Portrait) ? v.CurrentForm.bodyGraphicData.drawSize : v.CurrentForm.bodyGraphicData.drawSize) .y); } else { scaleVector = new Vector3(0, 0, 0); } GenDraw.DrawMeshNowOrLater(mesh, loc + scaleVector, quat, damagedMat, flags.FlagSet(PawnRenderFlags.DrawNow)); //HasFlag(PawnRenderFlags.Portrait)); //GenDraw.DrawMeshNowOrLater(mesh, Matrix4x4.TRS(loc + scaleVector, quat, Vector3.one), damagedMat, flags.FlagSet(PawnRenderFlags.DrawNow)); loc.y += 0.0046875f; } if (bodyDrawType == RotDrawMode.Fresh) { Vector3 drawLoc = rootLoc; drawLoc.y += 0.01875f; Traverse.Create(__instance).Field("woundOverlays").GetValue <PawnWoundDrawer>().RenderOverBody(drawLoc, mesh, quat, flags.FlagSet(PawnRenderFlags.DrawNow), BodyTypeDef.WoundLayer.Body, bodyFacing); //Traverse.Create(__instance).Field("woundOverlays").GetValue<PawnWoundDrawer>().RenderOverBody(drawLoc, mesh, quat, flags.HasFlag(PawnRenderFlags.Portrait), BodyTypeDef.WoundLayer.Body, bodyFacing); } } } return(false); } else if (!v.Transformed && v.CurFormGraphic != null) { v.CurFormGraphic = null; __instance.graphics.ResolveAllGraphics(); } } return(true); }
private void RenderPawnInternal(Vector3 rootLoc, float angle, bool renderBody, RotDrawMode draw, bool headStump, bool invisible, int curLevel, int baseLevel) { this.RenderPawnInternal(rootLoc, angle, renderBody, this.pawn.Rotation, this.pawn.Rotation, draw, false, headStump, invisible, curLevel, baseLevel); }
public static void Postfix(PawnRenderer __instance, ref Vector3 rootLoc, float angle, bool renderBody, Rot4 bodyFacing, Rot4 headFacing, RotDrawMode bodyDrawType, bool portrait, bool headStump) { if (AnotherModCheck.ShowHair_On) { Pawn pawn = (Pawn)PawnFI.GetValue(__instance); rootLoc = Children_Drawing.ModifyChildYPosOffset(rootLoc, pawn, portrait); } }
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 - (((float)(curLevel) - (float)baseLevel) / 5f)); 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 - (((float)(curLevel) - (float)baseLevel) / 5f); drawSize.y *= 1f - (((float)(curLevel) - (float)baseLevel) / 5f); 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 - (((float)(curLevel) - (float)baseLevel) / 5f)); 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); 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 static bool RenderHulk(PawnRenderer __instance, Vector3 rootLoc, Quaternion quat, bool renderBody, Rot4 bodyFacing, Rot4 headFacing, RotDrawMode bodyDrawType, bool portrait, bool headStump) { Pawn p = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); if (p?.GetComp <CompHulk>() is CompHulk compHulk && compHulk.IsTransformed) { if (compHulk.CurrentHulkForm.bodyGraphicData == null || __instance.graphics.nakedGraphic == null) { compHulk.CurrentHulkForm.bodyGraphicData = compHulk.CurrentHulkForm.def.graphicData; __instance.graphics.nakedGraphic = compHulk.CurrentHulkForm.bodyGraphicData.Graphic; } Mesh mesh = null; if (renderBody) { Vector3 loc = rootLoc; loc.y += 0.0046875f; if (bodyDrawType == RotDrawMode.Dessicated && !p.RaceProps.Humanlike && __instance.graphics.dessicatedGraphic != null && !portrait) { __instance.graphics.dessicatedGraphic.Draw(loc, bodyFacing, p); } else { mesh = __instance.graphics.nakedGraphic.MeshAt(bodyFacing); List <Material> list = __instance.graphics.MatsBodyBaseAt(bodyFacing, bodyDrawType); for (int i = 0; i < list.Count; i++) { Material damagedMat = __instance.graphics.flasher.GetDamagedMat(list[i]); Vector3 scaleVector = new Vector3(loc.x, loc.y, loc.z); if (portrait) { scaleVector.x *= 1f + (1f - (portrait ? compHulk.CurrentHulkForm.def.CustomPortraitDrawSize : compHulk.CurrentHulkForm.bodyGraphicData.drawSize) .x); scaleVector.z *= 1f + (1f - (portrait ? compHulk.CurrentHulkForm.def.CustomPortraitDrawSize : compHulk.CurrentHulkForm.bodyGraphicData.drawSize) .y); } else { scaleVector = new Vector3(0, 0, 0); } GenDraw.DrawMeshNowOrLater(mesh, loc + scaleVector, quat, damagedMat, portrait); loc.y += 0.0046875f; } if (bodyDrawType == RotDrawMode.Fresh) { Vector3 drawLoc = rootLoc; drawLoc.y += 0.01875f; Traverse.Create(__instance).Field("woundOverlays").GetValue <PawnWoundDrawer>().RenderOverBody(drawLoc, mesh, quat, portrait); } } } return(false); } return(true); }
static void Prefix(PawnRenderer __instance, ref Vector3 rootLoc, ref float angle, ref bool renderBody, ref Rot4 bodyFacing, ref Rot4 headFacing, ref RotDrawMode bodyDrawType, ref bool portrait, ref bool headStump, ref bool invisible) { Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); // bool selected = Find.Selector.SelectedObjects.Contains(pawn) && Prefs.DevMode; if (invisible) { return; } if (!portrait) { if (pawn.RaceProps.Humanlike && pawn.CurrentBed() != null && pawn.CurrentBed().GetType() == typeof(Building_XenomorphCocoon)) { //rootLoc.z += 1f; //rootLoc.x += 1f; if (pawn.CurrentBed().Rotation == Rot4.North) { //rootLoc.x += 0.5f; rootLoc.z -= 0.5f; } else if (pawn.CurrentBed().Rotation == Rot4.South) { //rootLoc.x += 0.5f; rootLoc.z += 0.5f; } else if (pawn.CurrentBed().Rotation == Rot4.East) { rootLoc.x -= 0.5f; //rootLoc.z += 0.5f; } else if (pawn.CurrentBed().Rotation == Rot4.West) { rootLoc.x += 0.5f; //rootLoc.z += 0.5f; } else { rootLoc = pawn.CurrentBed().DrawPos; } } bool pawnflag = !((pawn.kindDef.race.defName.StartsWith("Android") && pawn.kindDef.race.defName.Contains("Tier")) || pawn.kindDef.race.defName.Contains("ChjDroid") || pawn.kindDef.race.defName.Contains("ChjBattleDroid") || pawn.kindDef.race.defName.Contains("M7Mech")); if ((pawn.RaceProps.Humanlike && pawnflag) || pawn.kindDef.race.GetModExtension <OffsetDefExtension>() != null) { foreach (var hd in pawn.health.hediffSet.hediffs) { HediffComp_DrawImplant comp = hd.TryGetComp <HediffComp_DrawImplant>(); if (comp != null) { DrawImplant(comp, __instance, rootLoc, angle, renderBody, bodyFacing, headFacing, bodyDrawType, portrait, headStump); } } /* */ } // DrawWornExtras() else { foreach (var hd in pawn.health.hediffSet.hediffs) { HediffComp_DrawImplant comp = hd.TryGetComp <HediffComp_DrawImplant>(); if (comp != null) { comp.DrawWornExtras(); } } } } }
public virtual void DrawBasicHead(Vector3 drawLoc, Quaternion headQuat, RotDrawMode bodyDrawType, bool headStump, bool portrait, out bool headDrawn) { headDrawn = false; }
public static void Postfix(PawnRenderer __instance, Pawn ___pawn, Vector3 rootLoc, float angle, bool renderBody, Rot4 bodyFacing, Rot4 headFacing, RotDrawMode bodyDrawType, bool portrait, bool headStump, bool invisible) { Pawn p = ___pawn; if (!Genital_Helper.has_penis_fertile(p) && !Genital_Helper.has_penis_infertile(p) && !Genital_Helper.has_multipenis(p)) { return; } string originalPath = __instance.graphics.nakedGraphic.path; string modifiedPath = originalPath + "_Lewd"; if (ContentFinder <Texture2D> .Get(modifiedPath + "_north", false) != null) { if (p?.jobs?.curDriver != null && p.jobs.curDriver is JobDriver_Sex || (timeSinceSex.ContainsKey(p))) { GraphicData originalGraphicData = p.ageTracker.CurKindLifeStage.bodyGraphicData; Graphic lewdGraphic = CachedGraphics.LewdGraphics.TryGetValue(modifiedPath); if (lewdGraphic != null) { Mesh lewdMesh = lewdGraphic.MeshAt(bodyFacing); rootLoc.y = (AltitudeLayer.LayingPawn - 1).AltitudeFor(); GenDraw.DrawMeshNowOrLater(lewdMesh, rootLoc, Quaternion.AngleAxis(angle, Vector3.up), lewdGraphic.MatAt(bodyFacing), portrait); } } if (p?.jobs?.curDriver != null && p.jobs.curDriver is JobDriver_Sex) { if (p.jobs.curDriver.ticksLeftThisToil <= 30f) { if (timeSinceSex.ContainsKey(p)) { timeSinceSex[p] = GenTicks.TicksGame - Rand.Range(0, 180); } else { timeSinceSex.Add(p, GenTicks.TicksGame); } } } else if (timeSinceSex.ContainsKey(p) && timeSinceSex[p] + 1000 < GenTicks.TicksGame) //time delay to disappearing texture on job end { timeSinceSex.Remove(p); } } }
public virtual void DrawHairAndHeadGear(Vector3 hairLoc, Vector3 headgearLoc, RotDrawMode bodyDrawType, Quaternion headQuat, bool renderBody, bool portrait, Vector3 hatInFrontOfFace) { }
public static int CalculateGraphicsHash(this PawnGraphicSet graphicsSet, TerrainMovementPawnKindGraphics graphicsExt, Rot4 facing, RotDrawMode bodyCondition) { int num = facing.AsInt + 1000 * (int)bodyCondition; if (graphicsExt != null) { num += graphicsExt.pawnSpeedStat.GetHashCode(); } return(num); }
public virtual void DrawWrinkles(Vector3 drawLoc, RotDrawMode bodyDrawType, Quaternion headQuat, bool portrait) { }
private void RenderPawnInternal(Vector3 rootLoc, Quaternion quat, bool renderBody, RotDrawMode draw, bool headStump) { this.RenderPawnInternal(rootLoc, quat, renderBody, this.pawn.Rotation, this.pawn.Rotation, draw, false, headStump); }
public static void PawnRenderer_RenderPawnInternal_Postfix(ref PawnRenderer __instance, Vector3 rootLoc, float angle, bool renderBody, Rot4 bodyFacing, Rot4 headFacing, RotDrawMode bodyDrawType = RotDrawMode.Fresh, bool portrait = false, bool headStump = false) { if (!__instance.graphics.AllResolved) { __instance.graphics.ResolveAllGraphics(); } Mesh mesh = null; Quaternion quat = Quaternion.AngleAxis(angle, Vector3.up); Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); if (AdeptusIntergrationUtil.enabled_AlienRaces) { AM_PawnRenderer_RenderPawnInternal_DrawExtras_Patch.AlienRacesPatch(ref __instance, rootLoc, angle, renderBody, bodyFacing, headFacing, out mesh, bodyDrawType, portrait, headStump); } else { if (pawn.RaceProps.Humanlike) { mesh = MeshPool.humanlikeBodySet.MeshAt(bodyFacing); } else { mesh = __instance.graphics.nakedGraphic.MeshAt(bodyFacing); } } if (renderBody) { Vector3 vector = rootLoc; if (pawn.apparel != null && pawn.apparel.WornApparelCount > 0) { for (int k = 0; k < pawn.apparel.WornApparel.Count; k++) { if (pawn.apparel.WornApparel[k].TryGetComp <CompPauldronDrawer>() != null) { foreach (CompPauldronDrawer Pauldron in pawn.apparel.WornApparel[k].AllComps.Where(x => x.GetType() == typeof(CompPauldronDrawer))) { if (!Pauldron.Props.PauldronEntries.NullOrEmpty()) { if (!Pauldron.pauldronInitialized) { if (Rand.Chance(Pauldron.Props.PauldronEntryChance)) { Pauldron.shoulderPadEntry = Pauldron.Props.PauldronEntries.RandomElementByWeight((ShoulderPadEntry x) => x.commonality); Pauldron.pauldronGraphicPath = Pauldron.shoulderPadEntry.padTexPath; Pauldron.useSecondaryColor = Pauldron.shoulderPadEntry.UseSecondaryColor; Pauldron.padType = Pauldron.shoulderPadEntry.shoulderPadType; } Pauldron.pauldronInitialized = true; } if (Pauldron.ShouldDrawPauldron(pawn, bodyFacing, out Material pauldronMat)) { vector.y += Pauldron.GetAltitudeOffset(bodyFacing); GenDraw.DrawMeshNowOrLater(mesh, vector, quat, pauldronMat, portrait); // vector.y += CompPauldronDrawer.MinClippingDistance; } } } } if (pawn.apparel.WornApparel[k].TryGetComp <CompApparelExtraDrawer>() != null) { foreach (CompApparelExtraDrawer Extas in pawn.apparel.WornApparel[k].AllComps.Where(x => x.GetType() == typeof(CompApparelExtraDrawer))) { if (!Extas.pprops.ExtrasEntries.NullOrEmpty()) { if (Extas.ShouldDrawExtra(pawn, pawn.apparel.WornApparel[k], bodyFacing, out Material extraMat)) { Vector3 drawAt = vector; if (Extas.onHead) { drawAt = vector + __instance.BaseHeadOffsetAt(headFacing); } drawAt.y += Extas.GetAltitudeOffset(bodyFacing, Extas.ExtraPartEntry); GenDraw.DrawMeshNowOrLater(mesh, drawAt, quat, extraMat, portrait); // vector.y += CompApparelExtaDrawer.MinClippingDistance; } } } } Apparel_VisibleAccessory VisibleAccessory; if (pawn.apparel.WornApparel[k].GetType() == typeof(Apparel_VisibleAccessory)) { VisibleAccessory = (Apparel_VisibleAccessory)pawn.apparel.WornApparel[k]; } //ApparelGraphicRecord apparelGraphicRecord = __instance.graphics.apparelGraphics[k]; //if (apparelGraphicRecord.sourceApparel.def.apparel.LastLayer == ApparelLayer.Shell) //{ // Material material2 = apparelGraphicRecord.graphic.MatAt(bodyFacing, null); // material2 = __instance.graphics.flasher.GetDamagedMat(material2); // GenDraw.DrawMeshNowOrLater(mesh, vector, quat, material2, portrait); //} } } if (!pawn.Dead) { for (int l = 0; l < pawn.health.hediffSet.hediffs.Count; l++) { Vector3 drawAt = vector; HediffComp_DrawImplant_AdMech drawer = pawn.health.hediffSet.hediffs[l].TryGetComp <HediffComp_DrawImplant_AdMech>(); if (drawer != null) { Material material = null; if (drawer.implantDrawProps.implantDrawerType != ImplantDrawerType.Head) { drawAt.y += 0.005f; if (bodyFacing == Rot4.South && drawer.implantDrawProps.implantDrawerType == ImplantDrawerType.Backpack) { drawAt.y -= 0.3f; } material = drawer.ImplantMaterial(pawn, bodyFacing); // GenDraw.DrawMeshNowOrLater(mesh, drawAt, quat, material, portrait); } else { if (!pawn.Downed && !pawn.Dead && drawer.implantDrawProps.useHeadOffset) { drawAt = vector + __instance.BaseHeadOffsetAt(headFacing); } else { if (pawn.Downed || pawn.Dead && drawer.implantDrawProps.useHeadOffset) { drawAt.y = vector.y + __instance.BaseHeadOffsetAt(headFacing).y; } } drawAt.y += 0.005f; material = drawer.ImplantMaterial(pawn, headFacing); // GenDraw.DrawMeshNowOrLater(mesh, drawAt, quat, material, portrait); } if (material != null) { // GenDraw.DrawMeshNowOrLater(mesh, drawAt , quat, material, portrait); // Angle calculation to not pick the shortest, taken from Quaternion.Angle and modified GenDraw.DrawMeshNowOrLater(mesh: mesh, loc: drawAt + drawer.offsetVector().RotatedBy(angle: Mathf.Acos(f: Quaternion.Dot(a: Quaternion.identity, b: quat)) * 2f * 57.29578f), quat: quat, mat: material, drawNow: portrait); drawAt.y += HediffComp_DrawImplant_AdMech.MinClippingDistance; } } HediffComp_Shield _Shield; if ((_Shield = pawn.health.hediffSet.hediffs[l].TryGetComp <HediffComp_Shield>()) != null) { _Shield.DrawWornExtras(); } } } } }
public void RenderPawnAt(Vector3 drawLoc, RotDrawMode bodyDrawType, bool headStump) { if (!this.graphics.AllResolved) { this.graphics.ResolveAllGraphics(); } if (this.pawn.GetPosture() == PawnPosture.Standing) { this.RenderPawnInternal(drawLoc, Quaternion.identity, true, bodyDrawType, headStump); if (this.pawn.carryTracker != null) { Thing carriedThing = this.pawn.carryTracker.CarriedThing; if (carriedThing != null) { Vector3 vector = drawLoc; bool flag = false; bool flip = false; if (this.pawn.CurJob == null || !this.pawn.jobs.curDriver.ModifyCarriedThingDrawPos(ref vector, ref flag, ref flip)) { if (carriedThing is Pawn || carriedThing is Corpse) { vector += new Vector3(0.44f, 0f, 0f); } else { vector += new Vector3(0.18f, 0f, 0.05f); } } if (flag) { vector.y -= 0.0390625f; } else { vector.y += 0.0390625f; } carriedThing.DrawAt(vector, flip); } } if (this.pawn.def.race.specialShadowData != null) { if (this.shadowGraphic == null) { this.shadowGraphic = new Graphic_Shadow(this.pawn.def.race.specialShadowData); } this.shadowGraphic.Draw(drawLoc, Rot4.North, this.pawn, 0f); } if (this.graphics.nakedGraphic != null && this.graphics.nakedGraphic.ShadowGraphic != null) { this.graphics.nakedGraphic.ShadowGraphic.Draw(drawLoc, Rot4.North, this.pawn, 0f); } } else { Rot4 rot = this.LayingFacing(); Building_Bed building_Bed = this.pawn.CurrentBed(); bool renderBody; Quaternion quat; Vector3 rootLoc; if (building_Bed != null && this.pawn.RaceProps.Humanlike) { renderBody = building_Bed.def.building.bed_showSleeperBody; Rot4 rotation = building_Bed.Rotation; rotation.AsInt += 2; quat = rotation.AsQuat; AltitudeLayer altLayer = (AltitudeLayer)Mathf.Max((int)building_Bed.def.altitudeLayer, 15); Vector3 vector2 = this.pawn.Position.ToVector3ShiftedWithAltitude(altLayer); Vector3 vector3 = vector2; vector3.y += 0.02734375f; float d = -this.BaseHeadOffsetAt(Rot4.South).z; Vector3 a = rotation.FacingCell.ToVector3(); rootLoc = vector2 + a * d; rootLoc.y += 0.0078125f; } else { renderBody = true; rootLoc = drawLoc; if (!this.pawn.Dead && this.pawn.CarriedBy == null) { rootLoc.y = Altitudes.AltitudeFor(AltitudeLayer.LayingPawn) + 0.0078125f; } if (this.pawn.Downed || this.pawn.Dead) { quat = Quaternion.AngleAxis(this.wiggler.downedAngle, Vector3.up); } else if (this.pawn.RaceProps.Humanlike) { quat = rot.AsQuat; } else { Rot4 rot2 = Rot4.West; int num = this.pawn.thingIDNumber % 2; if (num != 0) { if (num == 1) { rot2 = Rot4.East; } } else { rot2 = Rot4.West; } quat = rot2.AsQuat; } } this.RenderPawnInternal(rootLoc, quat, renderBody, rot, rot, bodyDrawType, false, headStump); } if (this.pawn.Spawned && !this.pawn.Dead) { this.pawn.stances.StanceTrackerDraw(); this.pawn.pather.PatherDraw(); } this.DrawDebug(); }
static void AlienRacesPatch(ref PawnRenderer __instance, Vector3 rootLoc, float angle, bool renderBody, Rot4 bodyFacing, Rot4 headFacing, out Mesh mesh, RotDrawMode bodyDrawType = RotDrawMode.Fresh, bool portrait = false, bool headStump = false) { mesh = null; Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); AlienRace.ThingDef_AlienRace alienDef = pawn.def as AlienRace.ThingDef_AlienRace; if (alienDef != null) { Mesh mesh2; if (bodyDrawType == RotDrawMode.Rotting) { if (__instance.graphics.dessicatedGraphic.ShouldDrawRotated) { mesh2 = MeshPool.GridPlane(portrait ? alienDef.alienRace.generalSettings.alienPartGenerator.customPortraitDrawSize : alienDef.alienRace.generalSettings.alienPartGenerator.customDrawSize); } else { Vector2 size = portrait ? alienDef.alienRace.generalSettings.alienPartGenerator.customPortraitDrawSize : alienDef.alienRace.generalSettings.alienPartGenerator.customDrawSize; if (bodyFacing.IsHorizontal) { size = size.Rotated(); } if (bodyFacing == Rot4.West && (__instance.graphics.dessicatedGraphic.data == null || __instance.graphics.dessicatedGraphic.data.allowFlip)) { mesh = MeshPool.GridPlaneFlip(size); } mesh = MeshPool.GridPlane(size); } } else { AlienRace.AlienPartGenerator.AlienComp comp = pawn.TryGetComp <AlienRace.AlienPartGenerator.AlienComp>(); if (comp != null) { mesh = (portrait ? comp.alienPortraitGraphics.bodySet.MeshAt(bodyFacing) : comp.alienGraphics.bodySet.MeshAt(bodyFacing)); } } } else { if (pawn.RaceProps.Humanlike) { mesh = MeshPool.humanlikeBodySet.MeshAt(bodyFacing); } else { mesh = __instance.graphics.nakedGraphic.MeshAt(bodyFacing); } } }
public static bool Prefix(PawnGraphicSet __instance, ref Material __result, Rot4 facing, RotDrawMode bodyCondition = RotDrawMode.Fresh, bool stump = false, bool portrait = false, bool allowOverride = true) { return(PawnGraphicSet_HairMatAt_Patch.ShouldShowHead(__instance.pawn, portrait)); }
public static void DrawBackHairLayer(PawnRenderer __instance, ref Vector3 rootLoc, ref float angle, ref Rot4 headFacing, ref RotDrawMode bodyDrawType, ref bool portrait, ref bool headStump) { PawnGraphicSet graphics = __instance.graphics; if (!graphics.AllResolved) { graphics.ResolveAllGraphics(); } Graphic_Multi_BHair hairGraphicExtended = graphics.hairGraphic as Graphic_Multi_BHair; //if has head and hair graphics if (graphics.headGraphic != null && hairGraphicExtended != null) { Material hairMat = hairGraphicExtended.BackMatAt(headFacing); if (hairMat != null) { //-------------------------REPLICATED VANILLA CODE------------------------- Quaternion quaternion = Quaternion.AngleAxis(angle, new Vector3(0f, 1f, 0f)); Vector3 b = quaternion * __instance.BaseHeadOffsetAt(headFacing); Vector3 loc2 = rootLoc + b; //-------------------------REPLICATED VANILLA CODE------------------------- //loc2.y -= 0.0303030312f; //changed from original, used to be += bool hideHair = false; if (!portrait || !Prefs.HatsOnlyOnMap) { 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) { if (HarmonyPatches_BHair.loadedShowHair) { hideHair = Compat_ShowHair.SHCompat_ShouldHideHair(graphics.pawn, apparelGraphics[j].sourceApparel.def, portrait); } else if (HarmonyPatches_BHair.loadedHatDisplaySelection) { hideHair = Compat_HatDisplaySelection.HDCompat_ShouldHideHair(graphics.pawn, apparelGraphics[j].sourceApparel.def.defName); } else { hideHair = true; } } } } } if (!hideHair && bodyDrawType != RotDrawMode.Dessicated && !headStump) { if (graphics.pawn.IsInvisible()) { hairMat = InvisibilityMatPool.GetInvisibleMat(hairMat); } Material resultMat = graphics.flasher.GetDamagedMat(hairMat); Mesh hairMesh = null; if (HarmonyPatches_BHair.loadedAlienRace) { //use modified hair mesh after processed by Alien Race/Babies And Children hairMesh = Patch_AlienRace.ARCompat_GetCopiedMesh(); } if (HarmonyPatches_BHair.loadedRimWorldChildren) { //use modified hair mesh after processed by RimWorldChildren hairMesh = Patch_RimWorldChildren.RCCompat_GetCopiedMesh(); resultMat = Patch_RimWorldChildren.RCCompat_ModifyHairForChild(resultMat, graphics.pawn); //alternate calling method for manual calling //hairMesh = Compat_RimWorldChildren.RCCompat_GetModifiedPawnHairMesh(graphics, graphics.pawn, headFacing); } if (hairMesh == null) { //default hairMesh = graphics.HairMeshSet.MeshAt(headFacing); } GenDraw.DrawMeshNowOrLater(mesh: hairMesh, mat: resultMat, loc: loc2, quat: quaternion, drawNow: portrait); } } } }