public static PawnRenderFlags ChangeFlags(PawnRenderFlags pawnRenderFlags) { pawnRenderFlags |= PawnRenderFlags.Headgear; pawnRenderFlags |= PawnRenderFlags.Clothes; return(pawnRenderFlags); }
public static bool Prefix(Pawn ___pawn, Vector3 rootLoc, Rot4 pawnRotation, PawnRenderFlags flags) { if (___pawn.jobs?.curDriver is JobDriver_PlayArchery playArchery) { playArchery.DrawEquipment(rootLoc, pawnRotation, flags); return(false); } return(true); }
public static void Prefix(PawnRenderer __instance, Pawn ___pawn, Vector3 rootLoc, Vector3 headOffset, float angle, Rot4 bodyFacing, Rot4 headFacing, RotDrawMode bodyDrawType, PawnRenderFlags flags) { pawn = ___pawn; if (pawn == null || __instance == null) { return; } isDrafted = pawn.RaceProps.Humanlike && pawn.Drafted; apparelGraphics = __instance.graphics.apparelGraphics; Patch_PawnRenderer_DrawHeadHair.flags = flags; Patch_PawnRenderer_DrawHeadHair.headFacing = headFacing; skipDontShaveHead = false; }
public void DrawEquipment(Vector3 rootLoc, Rot4 pawnRotation, PawnRenderFlags flags) { if (pawn.pather.Moving) { return; } Vector3 drawLoc = new Vector3(0f, (pawnRotation == Rot4.North) ? (-0.00289575267f) : 0.03474903f, 0f); Vector3 vector = TargetA.Thing.DrawPos; float num = 0f; if ((vector - pawn.DrawPos).MagnitudeHorizontalSquared() > 0.001f) { num = (vector - pawn.DrawPos).AngleFlat(); } drawLoc += rootLoc + new Vector3(0f, 0f, 0.4f).RotatedBy(num); if (bow is null) { bow = ThingMaker.MakeThing(VFEM_DefOf.Bow_Great); } DrawEquipmentAiming(bow, drawLoc, num); }
public bool ShouldDrawEntry(PawnRenderFlags flags, Rot4 bodyFacing, Vector2 size, bool renderBody, out Graphic pauldronMaterial, out Mesh pauldronMesh, out Vector3 offset) { this.size = size; pauldronMaterial = null; offset = OffsetFor(bodyFacing); if (!renderBody) { if (!Drawer.onHead || (Props.drawInBed.HasValue && Props.drawInBed.Value == false)) { pauldronMesh = null; return(false); } } pauldronMesh = this.MeshSet.MeshAt(bodyFacing); if (pauldronMesh == null) { pauldronMesh = !Drawer.onHead ? MeshPool.humanlikeBodySet.MeshAt(bodyFacing) : MeshPool.humanlikeHeadSet.MeshAt(bodyFacing); if (AdeptusIntergrationUtility.enabled_AlienRaces) { pauldronMesh = GetPauldronMesh(flags, apparel.Wearer, bodyFacing, !Drawer.onHead); } } if (apparel.Wearer.RaceProps.Humanlike) { if (this.CheckPauldronRotation(bodyFacing)) { if (Graphic == null || (Graphic != null && Drawer.pawn != apparel.Wearer)) { // // Log.Message(string.Format("ShouldDrawPauldron UpdatePadGraphic")); UpdateGraphic(); } pauldronMaterial = Graphic;//.GetColoredVersion(shader, this.mainColorFor(Entry), this.secondaryColorFor(Entry)).MatAt(bodyFacing, this.parent); return(true); } } return(false); }
public override void DrawWornExtras() { base.DrawWornExtras(); if (!Pauldrons.NullOrEmpty()) { PawnRenderFlags flags = Wearer.Drawer.renderer.GetDefaultRenderFlags(Wearer); Quaternion quat = Quaternion.AngleAxis(0, Vector3.up); Vector3 vector = Wearer.Drawer.renderer.GetBodyPos(Wearer.DrawPos, out bool renderBody); Rot4 headfacing = Wearer.Rotation; Rot4 bodyFacing = Wearer.Rotation; bool portrait = flags.FlagSet(PawnRenderFlags.Portrait); Vector2 size = (portrait ? MeshPool.humanlikeBodySet.MeshAt(bodyFacing).bounds.size : Wearer.Drawer.renderer.graphics.nakedGraphic.MeshAt(bodyFacing).bounds.size); if (AdeptusIntergrationUtility.enabled_AlienRaces) { PawnRenderUtility.AlienRacesPatch(Wearer, bodyFacing, out size, portrait); } else { size = new Vector2(1.5f, 1.5f); } foreach (CompPauldronDrawer Pauldron in Pauldrons) { Vector3 center = vector + (quat * Pauldron.GetOffsetFor(bodyFacing, false)); if (Pauldron.activeEntries.NullOrEmpty()) { Pauldron.Initialize(); } foreach (ShoulderPadEntry entry in Pauldron.activeEntries) { // entry.Drawer = Pauldron; if (entry.apparel == null) { entry.apparel = this; } if (entry.Drawer == null) { Log.Warning("Warning! Drawer null"); } if (!entry.ForceDynamicDraw) { continue; } if (entry.ShouldDrawEntry(flags, bodyFacing, size, renderBody, out Graphic pauldronMat, out Mesh pauldronMesh, out Vector3 offset)) { if (Pauldron.onHead || renderBody) { Vector3 drawAt = Wearer.Drawer.DrawPos + (quat * Pauldron.GetOffsetFor(bodyFacing, false)); /* * drawAt.y += 0.009687258f; * drawAt.y += 0.022166021f; * drawAt.y += 0.028957527f; * drawAt.y += 0.97f; */ GenDraw.DrawMeshNowOrLater ( // pauldronMesh, PawnRenderUtility.GetPawnMesh(portrait, Wearer, entry.Props.flipWest && bodyFacing == Rot4.West ? bodyFacing.Opposite : bodyFacing, !Pauldron.onHead), drawAt + (quat * offset), quat, PawnRenderUtility.OverrideMaterialIfNeeded(pauldronMat.MatAt(bodyFacing), Wearer), flags.FlagSet(PawnRenderFlags.DrawNow) ); } } } } } if (!Extras.NullOrEmpty()) { PawnRenderFlags flags = Wearer.Drawer.renderer.GetDefaultRenderFlags(Wearer); Quaternion quat = Quaternion.AngleAxis(0, Vector3.up); Vector3 vector = Wearer.DrawPos; Rot4 headfacing = Wearer.Rotation; Rot4 bodyFacing = Wearer.Rotation; bool portrait = flags.FlagSet(PawnRenderFlags.Portrait); Vector2 size = (portrait ? MeshPool.humanlikeBodySet.MeshAt(bodyFacing).bounds.size : Wearer.Drawer.renderer.graphics.nakedGraphic.MeshAt(bodyFacing).bounds.size); if (AdeptusIntergrationUtility.enabled_AlienRaces) { PawnRenderUtility.AlienRacesPatch(Wearer, bodyFacing, out size, portrait); } else { size = new Vector2(1.5f, 1.5f); } foreach (CompApparelExtraPartDrawer ExtraDrawer in Extras) { Vector3 drawAt = Wearer.DrawPos; if (!ExtraDrawer.Props.ExtrasEntries.NullOrEmpty()) { bool onHead = ExtraDrawer.onHead || ExtraDrawer.ExtraPartEntry.OnHead || ExtraDrawer.Props.onHead; Rot4 facing = onHead ? headfacing : bodyFacing; if (!ExtraDrawer.ExtraPartEntry.DynamicDraw) { continue; } if (ExtraDrawer.ShouldDrawExtra(Wearer, this, facing, out Material extraMat)) { if (onHead || !PawnRenderFlagsExtension.FlagSet(flags, PawnRenderFlags.Invisible)) { if (onHead) { Vector3 v = vector + quat * Wearer.Drawer.renderer.BaseHeadOffsetAt(headfacing); drawAt = v + quat * new Vector3(ExtraDrawer.GetOffset(bodyFacing, ExtraDrawer.ExtraPartEntry).x *size.x, ExtraDrawer.GetOffset(bodyFacing, ExtraDrawer.ExtraPartEntry).y, ExtraDrawer.GetOffset(bodyFacing, ExtraDrawer.ExtraPartEntry).z *size.y); } else { drawAt = vector + (quat * new Vector3(ExtraDrawer.GetOffset(bodyFacing, ExtraDrawer.ExtraPartEntry).x *size.x, ExtraDrawer.GetOffset(bodyFacing, ExtraDrawer.ExtraPartEntry).y, ExtraDrawer.GetOffset(bodyFacing, ExtraDrawer.ExtraPartEntry).z *size.y)); } /* * GenDraw.DrawMeshNowOrLater * ( * // pauldronMesh, * PawnRenderUtility.GetPawnMesh(portrait, Wearer, facing, !onHead), * drawAt, * quat, * PawnRenderUtility.OverrideMaterialIfNeeded(extraMat, Wearer), * ExtraDrawer.ExtraPartEntry.animateExtra * ); */ Graphics.DrawMesh( PawnRenderUtility.GetPawnMesh(portrait, Wearer, facing, !onHead), drawAt, quat, PawnRenderUtility.OverrideMaterialIfNeeded(extraMat, Wearer), 0); } // vector.y += CompApparelExtaDrawer.MinClippingDistance; } } } } if (!Shields.NullOrEmpty()) { foreach (var item in Shields) { item.DrawShield(); } } }
// PawnRenderer.RenderPawnInternal private static bool RenderPawnInternal(PawnRenderer __instance, Vector3 rootLoc, bool renderBody, Rot4 bodyFacing, RotDrawMode bodyDrawType, PawnRenderFlags flags) { var value = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); CompWerewolf compWerewolf; bool result; if ((compWerewolf = value?.GetComp <CompWerewolf>()) != null && compWerewolf.IsTransformed) { if (compWerewolf.CurrentWerewolfForm.bodyGraphicData == null || __instance.graphics.nakedGraphic == null) { compWerewolf.CurrentWerewolfForm.bodyGraphicData = compWerewolf.CurrentWerewolfForm.def.graphicData; __instance.graphics.nakedGraphic = compWerewolf.CurrentWerewolfForm.bodyGraphicData.Graphic; } if (renderBody) { var vector = rootLoc; vector.y += 0.0046875f; if (bodyDrawType == RotDrawMode.Rotting && !value.RaceProps.Humanlike && __instance.graphics.dessicatedGraphic != null && (flags & PawnRenderFlags.Portrait) == 0) { __instance.graphics.dessicatedGraphic.Draw(vector, bodyFacing, value); } else { var mesh = __instance.graphics.nakedGraphic.MeshAt(bodyFacing); var list = __instance.graphics.MatsBodyBaseAt(bodyFacing, bodyDrawType); foreach (var baseMat in list) { var damagedMat = __instance.graphics.flasher.GetDamagedMat(baseMat); var vector2 = new Vector3(vector.x, vector.y, vector.z); if ((flags & PawnRenderFlags.Portrait) != 0) { vector2.x *= 1f + (1f - compWerewolf.CurrentWerewolfForm.def.CustomPortraitDrawSize.x); vector2.z *= 1f + (1f - compWerewolf.CurrentWerewolfForm.def.CustomPortraitDrawSize.y); } else { vector2 = Vector3.zero; } GenDraw.DrawMeshNowOrLater(mesh, vector + vector2, Quaternion.identity, damagedMat, true); vector.y += 0.0046875f; } if (bodyDrawType == 0) { var vector3 = rootLoc; vector3.y += 0.01875f; Traverse.Create(__instance).Field("woundOverlays").GetValue <PawnWoundDrawer>() .RenderOverBody(vector3, mesh, Quaternion.identity, true, BodyTypeDef.WoundLayer.Body, bodyFacing); } } } result = false; } else { result = true; } return(result); }
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); }
static void renderStaticEquipment(Pawn pawn, Rot4 bodyFacing, Vector3 vector, Quaternion quaternion, PawnRenderFlags flags) { if (!Settings.corpse_display_equipment || flags.FlagSet(PawnRenderFlags.Portrait) || !pawn.Dead || pawn.Spawned || pawn.equipment == null || pawn.equipment.Primary == null) { return; } var eq = pawn.equipment.Primary; var offset = eq.def.equippedAngleOffset % 360f; Graphic_StackCount graphic_StackCount = eq.Graphic as Graphic_StackCount; Material matSingle; if (graphic_StackCount == null) { matSingle = eq.Graphic.MatSingle; } else { matSingle = graphic_StackCount.SubGraphicForStackCount(1, eq.def).MatSingle; } float an = 0; Vector3 ax = Vector3.up; quaternion.ToAngleAxis(out an, out ax); GenDraw.DrawMeshNowOrLater(MeshPool.plane10, vector + quaternion * new Vector3(0, 0, -0.22f) + new Vector3(0f, 0.0367346928f, 0f), Quaternion.AngleAxis(-45f - (an - 180f) * 0.2f + offset, Vector3.up), matSingle, flags.FlagSet(PawnRenderFlags.DrawNow)); }
public static Mesh GetHeadMesh(PawnRenderFlags renderFlags, Pawn pawn, Rot4 headFacing, PawnGraphicSet graphics) { return(null); }
private static Material GetMaterial(PawnRenderer renderer, Pawn pawn, ApparelGraphicRecord record, Rot4 bodyFacing, PawnRenderFlags flags) { Material mat = record.graphic.MatAt(bodyFacing); if (flags.FlagSet(PawnRenderFlags.Cache)) { return(mat); } return((Material)mOverrideMaterialIfNeeded.Invoke(renderer, new object[] { mat, pawn, flags.FlagSet(PawnRenderFlags.Portrait) })); }
private static void DrawHeadApparel(PawnRenderer renderer, Pawn pawn, Vector3 rootLoc, Vector3 headLoc, Vector3 headOffset, Rot4 bodyFacing, Quaternion quaternion, PawnRenderFlags flags, Rot4 headFacing, ref bool hideHair) { if (flags.FlagSet(PawnRenderFlags.Portrait) && Prefs.HatsOnlyOnMap) { return; } if (!flags.FlagSet(PawnRenderFlags.Headgear)) { return; } List <ApparelGraphicRecord> apparelGraphics = renderer.graphics.apparelGraphics; // This will limit us to only 32 layers of headgear float interval = YOffsetIntervalClothes / 32; Vector3 customScale = Vec2ToVec3(GetHeadCustomSize(pawn.def)); Vector3 headwearPos = headLoc + Vec2ToVec3(GetHeadCustomOffset(pawn.def)); Mesh mesh = GetHeadMesh(flags, pawn, headFacing, renderer.graphics) ?? renderer.graphics.HairMeshSet.MeshAt(bodyFacing); for (int i = 0; i < apparelGraphics.Count; i++) { ApparelGraphicRecord apparelRecord = apparelGraphics[i]; if (apparelRecord.sourceApparel.def.apparel.LastLayer == ApparelLayerDefOf.Overhead && !apparelRecord.sourceApparel.def.apparel.hatRenderedFrontOfFace) { hideHair = apparelRecord.sourceApparel?.def?.GetModExtension <ApperalRenderingExtension>()?.HideHair ?? true; } else if (apparelRecord.sourceApparel.def.apparel.LastLayer.GetModExtension <ApparelLayerExtension>()?.IsHeadwear ?? false) { Material apparelMat = GetMaterial(renderer, pawn, apparelRecord, bodyFacing, flags); if (apparelRecord.sourceApparel.def.apparel.hatRenderedFrontOfFace) { Matrix4x4 matrix = new Matrix4x4(); Vector3 maskLoc = rootLoc + headOffset; maskLoc.y += !(bodyFacing == north) ? YOffsetPostHead : YOffsetBehind; matrix.SetTRS(maskLoc, quaternion, customScale); GenDraw.DrawMeshNowOrLater(mesh, matrix, apparelMat, flags.FlagSet(PawnRenderFlags.DrawNow)); } else { Matrix4x4 matrix = new Matrix4x4(); hideHair = apparelRecord.sourceApparel?.def?.GetModExtension <ApperalRenderingExtension>()?.HideHair ?? true; headwearPos.y += interval; matrix.SetTRS(headwearPos, quaternion, customScale); GenDraw.DrawMeshNowOrLater(mesh, matrix, apparelMat, flags.FlagSet(PawnRenderFlags.DrawNow)); } } } }
private static void RenderFacepaint(PawnRenderer instance, bool hideFacepaint, RotDrawMode bodyDrawType, PawnRenderFlags flags, Rot4 headFacing, Vector3 baseDrawPos, Quaternion quaternion) { var pawn = instance.graphics.pawn; if (bodyDrawType != RotDrawMode.Dessicated && !flags.FlagSet(PawnRenderFlags.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), flags.FlagSet(PawnRenderFlags.DrawNow)); } if (facepaintComp.facepaintGraphicTwo != null) { GenDraw.DrawMeshNowOrLater(mesh, baseDrawPos - new Vector3(0, 0.0005f, 0), quaternion, facepaintComp.facepaintGraphicTwo.MatAt(headFacing), flags.FlagSet(PawnRenderFlags.DrawNow)); } } }
public static void DrawAddons(ref PawnRenderFlags flags, Vector3 vector, Pawn pawn, Quaternion quat, Rot4 bodyFacing, Mesh mesh, Rot4 headfacing, bool renderBody) { if (!pawn.RaceProps.Humanlike || PawnRenderFlagsExtension.FlagSet(flags, (PawnRenderFlags)4)) { return; } /* * // Log.Message(string.Concat(new string[] * { * "DRAWING EXTRAS FOR: " + pawn.NameFullColored + " | " + flags.ToString() + " | ", * (!pawn.RaceProps.Humanlike || PawnRenderFlagsExtension.FlagSet(flags, (PawnRenderFlags)4)).ToString(), * " | ", * PawnRenderFlagsExtension.FlagSet(flags, (PawnRenderFlags)4).ToString(), * " | ", * (!pawn.RaceProps.Humanlike).ToString() * })); */ // Log.Message("DrawAddons "+ flags.ToString()); if (flags.FlagSet(PawnRenderFlags.Invisible)) { // Log.Message("PawnRenderFlags.Invisible"); return; } bool portrait = flags.FlagSet(PawnRenderFlags.Portrait); Vector2 defaultSize = mesh?.bounds.size ?? (portrait ? MeshPool.humanlikeBodySet.MeshAt(bodyFacing).bounds.size : pawn.Drawer.renderer.graphics.nakedGraphic.MeshAt(bodyFacing).bounds.size); Vector2 size = mesh?.bounds.size ?? (portrait ? MeshPool.humanlikeBodySet.MeshAt(bodyFacing).bounds.size : pawn.Drawer.renderer.graphics.nakedGraphic.MeshAt(bodyFacing).bounds.size); if (pawn.RaceProps.Humanlike) { if (pawn.apparel != null && pawn.apparel.WornApparelCount > 0) { // Log.Message("DrawAddons for "+ pawn.apparel.WornApparelCount+" apparel"); if (AdeptusIntergrationUtility.enabled_AlienRaces) { PawnRenderUtility.AlienRacesPatch(pawn, bodyFacing, out size, portrait); } else { size = new Vector2(1.5f, 1.5f); } List <Apparel> worn = pawn.apparel.WornApparel; for (int wa = 0; wa < worn.Count; wa++) { Apparel apparel = worn[wa]; if (apparel is ApparelComposite composite) { // Log.Message("composite"); if (!composite.Pauldrons.NullOrEmpty() && AMAMod.settings.AllowPauldronDrawer) { for (int i = 0; i < composite.Pauldrons.Count; i++) { CompPauldronDrawer Pauldron = composite.Pauldrons[i] as CompPauldronDrawer; if (Pauldron != null) { Vector3 center = vector + (quat * Pauldron.GetOffsetFor(bodyFacing, false)); if (Pauldron.activeEntries.NullOrEmpty()) { Pauldron.Initialize(); } foreach (ShoulderPadEntry entry in Pauldron.activeEntries) { // entry.Drawer = Pauldron; if (entry.apparel == null) { entry.apparel = apparel; } if (entry.Drawer == null) { Log.Warning("Warning! Drawer null"); } /* * if (entry.ForceDynamicDraw) * { * continue; * } */ if (entry.ShouldDrawEntry(flags, bodyFacing, size, renderBody, out Graphic pauldronMat, out Mesh pauldronMesh, out Vector3 offset)) { if (Pauldron.onHead || renderBody) { GenDraw.DrawMeshNowOrLater ( // pauldronMesh, PawnRenderUtility.GetPawnMesh(portrait, pawn, entry.Props.flipWest && bodyFacing == Rot4.West ? bodyFacing.Opposite : bodyFacing, !Pauldron.onHead), center + (quat * offset), quat, PawnRenderUtility.OverrideMaterialIfNeeded(pauldronMat.MatAt(bodyFacing), pawn), flags.FlagSet(PawnRenderFlags.DrawNow) ); } } } } } } if (!composite.Extras.NullOrEmpty() && AMAMod.settings.AllowExtraPartDrawer) { for (int i = 0; i < composite.Extras.Count; i++) { CompApparelExtraPartDrawer ExtraDrawer = composite.Extras[i]; if (ExtraDrawer != null) { if (ExtraDrawer.hidesHead) { flags |= PawnRenderFlags.HeadStump; } Vector3 drawAt = vector; if (!ExtraDrawer.Props.ExtrasEntries.NullOrEmpty()) { bool onHead = ExtraDrawer.onHead || ExtraDrawer.ExtraPartEntry.OnHead || ExtraDrawer.Props.onHead; Rot4 facing = onHead ? headfacing : bodyFacing; if (ExtraDrawer.ExtraPartEntry.DynamicDraw) { continue; } if (ExtraDrawer.ShouldDrawExtra(pawn, apparel, facing, out Material extraMat)) { if (onHead || renderBody) { if (onHead) { Vector3 v = vector + quat * pawn.Drawer.renderer.BaseHeadOffsetAt(headfacing); drawAt = v + quat * new Vector3(ExtraDrawer.GetOffset(bodyFacing, ExtraDrawer.ExtraPartEntry).x *size.x, ExtraDrawer.GetOffset(bodyFacing, ExtraDrawer.ExtraPartEntry).y, ExtraDrawer.GetOffset(bodyFacing, ExtraDrawer.ExtraPartEntry).z *size.y); } else { drawAt = vector + (quat * new Vector3(ExtraDrawer.GetOffset(bodyFacing, ExtraDrawer.ExtraPartEntry).x *size.x, ExtraDrawer.GetOffset(bodyFacing, ExtraDrawer.ExtraPartEntry).y, ExtraDrawer.GetOffset(bodyFacing, ExtraDrawer.ExtraPartEntry).z *size.y)); } GenDraw.DrawMeshNowOrLater ( // pauldronMesh, PawnRenderUtility.GetPawnMesh(portrait, pawn, facing, !onHead), drawAt, quat, PawnRenderUtility.OverrideMaterialIfNeeded(extraMat, pawn), flags.FlagSet(PawnRenderFlags.DrawNow) || ExtraDrawer.ExtraPartEntry.DynamicDraw ); } // vector.y += CompApparelExtaDrawer.MinClippingDistance; } } } } } } else { // Log.Message("noncomposite"); for (int i = 0; i < apparel.AllComps.Count; i++) { if (AMAMod.settings.AllowPauldronDrawer) { CompPauldronDrawer Pauldron = apparel.AllComps[i] as CompPauldronDrawer; if (Pauldron != null) { // Log.Message("Pauldron"); Vector3 center = vector + (quat * Pauldron.GetOffsetFor(bodyFacing, false)); if (Pauldron.activeEntries.NullOrEmpty()) { Pauldron.Initialize(); } foreach (ShoulderPadEntry entry in Pauldron.activeEntries) { // entry.Drawer = Pauldron; if (entry.apparel == null) { entry.apparel = apparel; } if (entry.Drawer == null) { Log.Warning("Warning! Drawer null"); } if (entry.ForceDynamicDraw) { continue; } if (entry.ShouldDrawEntry(flags, bodyFacing, size, renderBody, out Graphic pauldronMat, out Mesh pauldronMesh, out Vector3 offset)) { if (Pauldron.onHead || renderBody && pauldronMat != null) { // Log.Message("Pauldron DrawMeshNowOrLater " + !flags.FlagSet(PawnRenderFlags.Cache)); GenDraw.DrawMeshNowOrLater ( // pauldronMesh, PawnRenderUtility.GetPawnMesh(portrait, pawn, entry.Props.flipWest && bodyFacing == Rot4.West ? bodyFacing.Opposite : bodyFacing, !Pauldron.onHead), center + (quat * offset), quat, PawnRenderUtility.OverrideMaterialIfNeeded(pauldronMat.MatAt(bodyFacing), pawn), flags.FlagSet(PawnRenderFlags.DrawNow) ); } } } } } if (AMAMod.settings.AllowExtraPartDrawer) { CompApparelExtraPartDrawer ExtraDrawer = apparel.AllComps[i] as CompApparelExtraPartDrawer; if (ExtraDrawer != null) { // Log.Message("ExtraDrawer"); Vector3 drawAt = vector; if (!ExtraDrawer.Props.ExtrasEntries.NullOrEmpty()) { bool onHead = ExtraDrawer.onHead || ExtraDrawer.ExtraPartEntry.OnHead || ExtraDrawer.Props.onHead; Rot4 facing = onHead ? headfacing : bodyFacing; if (ExtraDrawer.ExtraPartEntry.DynamicDraw) { continue; } if (ExtraDrawer.ShouldDrawExtra(pawn, apparel, facing, out Material extraMat)) { if (onHead || renderBody) { if (onHead) { Vector3 v = vector + quat * pawn.Drawer.renderer.BaseHeadOffsetAt(headfacing); drawAt = v + quat * new Vector3(ExtraDrawer.GetOffset(bodyFacing, ExtraDrawer.ExtraPartEntry).x *size.x, ExtraDrawer.GetOffset(bodyFacing, ExtraDrawer.ExtraPartEntry).y, ExtraDrawer.GetOffset(bodyFacing, ExtraDrawer.ExtraPartEntry).z *size.y); } else { drawAt = vector + (quat * new Vector3(ExtraDrawer.GetOffset(bodyFacing, ExtraDrawer.ExtraPartEntry).x *size.x, ExtraDrawer.GetOffset(bodyFacing, ExtraDrawer.ExtraPartEntry).y, ExtraDrawer.GetOffset(bodyFacing, ExtraDrawer.ExtraPartEntry).z *size.y)); } // Log.Message("ExtraDrawer DrawMeshNowOrLater "+ !flags.FlagSet(PawnRenderFlags.Cache)); GenDraw.DrawMeshNowOrLater ( // pauldronMesh, PawnRenderUtility.GetPawnMesh(portrait, pawn, facing, !onHead), drawAt, quat, PawnRenderUtility.OverrideMaterialIfNeeded(extraMat, pawn), flags.FlagSet(PawnRenderFlags.DrawNow) || ExtraDrawer.ExtraPartEntry.DynamicDraw ); } // vector.y += CompApparelExtaDrawer.MinClippingDistance; } } } } } } } } } if (!pawn.Dead && AMAMod.settings.AllowHediffPartDrawer) { Vector3 drawAt = vector; for (int i = 0; i < AdeptusHediffUtility.GraphicHediffs.Count; i++) { if (pawn.health.hediffSet.GetFirstHediffOfDef(AdeptusHediffUtility.GraphicHediffs[i]) is HediffWithComps hediff) { if (hediff.TryGetCompFast <HediffComp_DrawImplant_AdMech>() is HediffComp_DrawImplant_AdMech drawer) { 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 + pawn.Drawer.renderer.BaseHeadOffsetAt(headfacing); } else { if ((pawn.Downed || pawn.Dead) && drawer.implantDrawProps.useHeadOffset) { drawAt.y = vector.y + pawn.Drawer.renderer.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); material = PawnRenderUtility.OverrideMaterialIfNeeded(material, pawn); // 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: flags.FlagSet(PawnRenderFlags.DrawNow)); drawAt.y += HediffComp_DrawImplant_AdMech.MinClippingDistance; } } } } /* * for (int hd = 0; hd < pawn.health.hediffSet.hediffs.Count; hd++) * { * Vector3 drawAt = vector; * HediffWithComps hediff = pawn.health.hediffSet.hediffs[hd] as HediffWithComps; * if (hediff != null) * { * for (int i = 0; i < hediff.comps.Count; i++) * { * HediffComp_DrawImplant_AdMech drawer = hediff.comps[i] as 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 + pawn.Drawer.renderer.BaseHeadOffsetAt(headfacing); * } * else * { * if (pawn.Downed || pawn.Dead && drawer.implantDrawProps.useHeadOffset) * { * drawAt.y = vector.y + pawn.Drawer.renderer.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); * * material = OverrideMaterialIfNeeded(material, pawn); * // 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 = hediff.comps[i] as HediffComp_Shield) != null) * { * _Shield.DrawWornExtras(); * } * } * } * } */ } }
Mesh GetPauldronMesh(PawnRenderFlags flags, Pawn pawn, Rot4 facing, bool body) { return(AlienRace.HarmonyPatches.GetPawnMesh(flags, pawn, facing, body)); }