//=================================== COMPDEFLECTOR //public static void SpecialDisplayStatsPostFix(Thing __instance, ref IEnumerable<StatDrawEntry> __result) //{ // ////Log.Message("3"); // ThingWithComps thingWithComps = __instance as ThingWithComps; // if (thingWithComps != null) // { // CompDeflector compDeflector = thingWithComps.GetComp<CompDeflector>(); // if (compDeflector != null) // { // List<StatDrawEntry> origin = new List<StatDrawEntry>(); // foreach (StatDrawEntry entry in __result) // { // //Log.Message("Entry"); // origin.Add(entry); // } // List<StatDrawEntry> entries = new List<StatDrawEntry>(); // foreach (StatDrawEntry entry in compDeflector.PostSpecialDisplayStats()) // { // //Log.Message("Hey!"); // entries.Add(entry); // } // origin.Concat(entries); // __result = origin; // } // } //} public static void DrawEquipmentAimingPostFix(PawnRenderer __instance, Thing eq, Vector3 drawLoc, float aimAngle) { Pawn pawn = (Pawn)AccessTools.Field(typeof(PawnRenderer), "pawn").GetValue(__instance); if (pawn != null) { ////Log.Message("1"); Pawn_EquipmentTracker pawn_EquipmentTracker = pawn.equipment; if (pawn_EquipmentTracker != null) { ////Log.Message("2"); foreach (ThingWithComps thingWithComps in pawn_EquipmentTracker.AllEquipmentListForReading) { ////Log.Message("3"); if (thingWithComps != null) { ////Log.Message("4"); ////Log.Message("3"); CompDeflector compDeflector = thingWithComps.GetComp <CompDeflector>(); if (compDeflector != null) { ////Log.Message("5"); if (compDeflector.IsAnimatingNow) { bool flip = false; if (!Find.TickManager.Paused && compDeflector.IsAnimatingNow) { compDeflector.AnimationDeflectionTicks -= 20; } float offset = eq.def.equippedAngleOffset; float num = aimAngle - 90f; if (aimAngle > 20f && aimAngle < 160f) { //mesh = MeshPool.plane10; num += offset; if (compDeflector.IsAnimatingNow) { num += ((compDeflector.AnimationDeflectionTicks + 1) / 2); } } else if (aimAngle > 200f && aimAngle < 340f) { //mesh = MeshPool.plane10Flip; flip = true; num -= 180f; num -= offset; if (compDeflector.IsAnimatingNow) { num -= ((compDeflector.AnimationDeflectionTicks + 1) / 2); } } else { //mesh = MeshPool.plane10; num += offset; if (compDeflector.IsAnimatingNow) { num += ((compDeflector.AnimationDeflectionTicks + 1) / 2); } } num %= 360f; Graphic_StackCount graphic_StackCount = eq.Graphic as Graphic_StackCount; Material matSingle; if (graphic_StackCount != null) { matSingle = graphic_StackCount.SubGraphicForStackCount(1, eq.def).MatSingle; } else { matSingle = eq.Graphic.MatSingle; } //mesh = MeshPool.GridPlane(thingWithComps.def.graphicData.drawSize); //Graphics.DrawMesh(mesh, drawLoc, Quaternion.AngleAxis(num, Vector3.up), matSingle, 0); Vector3 s = new Vector3(eq.def.graphicData.drawSize.x, 1f, eq.def.graphicData.drawSize.y); Matrix4x4 matrix = default(Matrix4x4); matrix.SetTRS(drawLoc, Quaternion.AngleAxis(num, Vector3.up), s); if (!flip) { Graphics.DrawMesh(MeshPool.plane10, matrix, matSingle, 0); } else { Graphics.DrawMesh(MeshPool.plane10Flip, matrix, matSingle, 0); } ////Log.Message("DeflectDraw"); } } } } } } }
public static void RenderPawnInternal(this PawnRenderer renderer, Vector3 rootLoc, Quaternion quat, bool renderBody, Rot4 bodyFacing, Rot4 headFacing, RotDrawMode bodyDrawType = RotDrawMode.Fresh, bool portrait = false) { Pawn rendererPawn = renderer.GetFieldViaReflection <Pawn>("pawn"); if (!renderer.graphics.AllResolved) { renderer.graphics.ResolveAllGraphics(); } Mesh mesh = null; if (renderBody) { Vector3 loc = rootLoc; loc.y += 0.005f; if (bodyDrawType == RotDrawMode.Dessicated && !rendererPawn.RaceProps.Humanlike && renderer.graphics.dessicatedGraphic != null && !portrait) { renderer.graphics.dessicatedGraphic.Draw(loc, bodyFacing, rendererPawn); } else { if (rendererPawn.RaceProps.Humanlike) { mesh = MeshPool.humanlikeBodySet.MeshAt(bodyFacing); } else { mesh = renderer.graphics.nakedGraphic.MeshAt(bodyFacing); } List <Material> list = renderer.graphics.MatsBodyBaseAt(bodyFacing, bodyDrawType); for (int i = 0; i < list.Count; i++) { Material damagedMat = renderer.graphics.flasher.GetDamagedMat(list[i]); GenDraw.DrawMeshNowOrLater(mesh, loc, quat, damagedMat, portrait); loc.y += 0.005f; } if (bodyDrawType == RotDrawMode.Fresh) { Vector3 drawLoc = rootLoc; drawLoc.y += 0.02f; renderer.GetFieldViaReflection <PawnWoundDrawer>("woundOverlays").RenderOverBody(drawLoc, mesh, quat, portrait); } } } Vector3 loc2 = rootLoc; Vector3 a = rootLoc; if (bodyFacing != Rot4.North) { a.y += 0.03f; loc2.y += 0.0249999985f; } else { a.y += 0.0249999985f; loc2.y += 0.03f; } if (renderer.graphics.headGraphic != null) { Vector3 b = quat * renderer.BaseHeadOffsetAt(headFacing); Mesh mesh2 = MeshPool.humanlikeHeadSet.MeshAt(headFacing); Material mat = renderer.graphics.HeadMatAt(headFacing, bodyDrawType); GenDraw.DrawMeshNowOrLater(mesh2, a + b, quat, mat, portrait); Vector3 loc3 = rootLoc + b; loc3.y += 0.035f; bool flag = false; if (!portrait) { Mesh mesh3 = renderer.graphics.HairMeshSet.MeshAt(headFacing); List <ApparelGraphicRecord> apparelGraphics = renderer.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 = renderer.graphics.flasher.GetDamagedMat(material); GenDraw.DrawMeshNowOrLater(mesh3, loc3, quat, material, portrait); } } } if (!flag && bodyDrawType != RotDrawMode.Dessicated) { Mesh mesh4 = renderer.graphics.HairMeshSet.MeshAt(headFacing); Material mat2 = renderer.graphics.HairMatAt(headFacing); GenDraw.DrawMeshNowOrLater(mesh4, loc3, quat, mat2, portrait); } } if (renderBody) { for (int k = 0; k < renderer.graphics.apparelGraphics.Count; k++) { ApparelGraphicRecord apparelGraphicRecord = renderer.graphics.apparelGraphics[k]; if (apparelGraphicRecord.sourceApparel.def.apparel.LastLayer == ApparelLayer.Shell) { Material material2 = apparelGraphicRecord.graphic.MatAt(bodyFacing, null); material2 = renderer.graphics.flasher.GetDamagedMat(material2); GenDraw.DrawMeshNowOrLater(mesh, loc2, quat, material2, portrait); } } } if (!portrait && rendererPawn.RaceProps.Animal && rendererPawn.inventory != null && rendererPawn.inventory.innerContainer.Count > 0) { Graphics.DrawMesh(mesh, loc2, quat, renderer.graphics.packGraphic.MatAt(rendererPawn.Rotation, null), 0); } if (!portrait) { renderer.CallMethodViaReflection("DrawEquipment", rootLoc); if (rendererPawn.apparel != null) { List <Apparel> wornApparel = rendererPawn.apparel.WornApparel; for (int l = 0; l < wornApparel.Count; l++) { wornApparel[l].DrawWornExtras(); } } Vector3 bodyLoc = rootLoc; bodyLoc.y += 0.0449999981f; renderer.GetFieldViaReflection <PawnHeadOverlays>("statusOverlays").RenderStatusOverlays(bodyLoc, quat, MeshPool.humanlikeHeadSet.MeshAt(headFacing)); } }
public void Draw() { HediffComp_DrawImplant comp = this.TryGetComp <HediffComp_DrawImplant>(); string direction = ""; float angle = 0f; float offset = 0f; Vector3 drawPos = pawn.Dead ? pawn.PositionHeld.ToVector3() : pawn.Drawer.DrawPos; drawPos.y = Altitudes.AltitudeFor((AltitudeLayer)17); Vector3 s = new Vector3(1.5f, 1.5f, 1.5f); PawnRenderer pawnRenderer = this.pawn.Drawer.renderer; Rot4 rot = LayingFacing(); bool selected = Find.Selector.SingleSelectedThing == pawn; bool flag3 = pawn.Rotation == Rot4.North; if (flag3) { //offset = NorthOffset; // drawPos.x -= 0.1f; // drawPos.z -= (0.2f); direction = "North"; } else { bool flag4 = pawn.Rotation == Rot4.South; if (flag4) { //offset = SouthOffset; // drawPos.x += 0.1f; // drawPos.z -= (0.2f); direction = "South"; } else { bool flag5 = pawn.Rotation == Rot4.East; if (flag5) { //offset = EastOffset; // drawPos.z -= (0.2f); // angle = 22.5f; direction = "East"; } else { bool flag6 = pawn.Rotation == Rot4.West; if (flag6) { //offset = WestOffset; // drawPos.z -= (0.2f); // angle = 337.5f; direction = "West"; } } } } if (offset < 0) { drawPos.y -= offset; } else { drawPos.y += offset; } //Log.Message(string.Format("PauldronGraphic drawPos.y: {1}", PauldronGraphic.path, drawPos.y)); angle = pawnRenderer.wiggler.downedAngle; //Material mat = apparelGraphic.graphic.MatAt(rotation); if (selected) { Log.Message(string.Format("{0}'s {1} CompPauldronDrawer, {2} offset: {3}, drawPos.y:{4}", pawn.Label, this.def.label, direction, offset, drawPos.y)); } Material matSingle = comp.ImplantMaterial(pawn, rot); //.GetColoredVersion(ShaderDatabase.Cutout, this.mainColor, this.secondaryColor).MatAt(rotation); // Log.Message(string.Format("PauldronGraphic this.mainColor:{0}, this.secondaryColor: {1}", this.mainColor, this.secondaryColor)); 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); }
public static Vector2 ForPawn(Pawn pawn) { if (pawn.RaceProps.Humanlike) { PawnRenderer renderer = pawn.Drawer.renderer; PawnGraphicSet graphicSet = renderer.graphics; if (!graphicSet.AllResolved) { graphicSet.ResolveAllGraphics(); } try { if (pawn.IsDessicated() && graphicSet.dessicatedGraphic != null) { return(BoundMap( graphicSet.dessicatedGraphic, GraphicType.Pawn, graphicSet.desiccatedHeadGraphic, new Vector2(renderer.BaseHeadOffsetAt(Rot4.South).x, renderer.BaseHeadOffsetAt(Rot4.East).z))); } return(BoundMap( graphicSet.nakedGraphic, GraphicType.Pawn, graphicSet.headGraphic, new Vector2(renderer.BaseHeadOffsetAt(Rot4.South).x, renderer.BaseHeadOffsetAt(Rot4.East).z))); } catch (ArgumentException e) { throw new ArgumentException(pawn + ".graphics." + (pawn.IsDessicated() ? "dessicated/dessicatedHead" : "naked/head") + "Graphic", e); } } else { PawnKindLifeStage lifeStage = pawn.ageTracker.CurKindLifeStage; try { if (pawn.IsDessicated() && lifeStage.dessicatedBodyGraphicData != null) { return(Vector2.Scale(BoundMap(lifeStage.dessicatedBodyGraphicData.Graphic, GraphicType.Pawn), lifeStage.dessicatedBodyGraphicData.drawSize)); } } catch (ArgumentException e) { throw new ArgumentException(pawn + ".lifeStage[" + pawn.ageTracker.CurLifeStageIndex + "].dessicatedBodyGraphicData", e); } try { if (pawn.gender == Gender.Female && lifeStage.femaleGraphicData != null) { return(Vector2.Scale(BoundMap(lifeStage.femaleGraphicData.Graphic, GraphicType.Pawn), lifeStage.femaleGraphicData.drawSize)); } } catch (ArgumentException e) { throw new ArgumentException(pawn + ".lifeStage[" + pawn.ageTracker.CurLifeStageIndex + "].femaleGraphicData", e); } try { if (lifeStage.bodyGraphicData != null) { return(Vector2.Scale(BoundMap(lifeStage.bodyGraphicData.Graphic, GraphicType.Pawn), lifeStage.bodyGraphicData.drawSize)); } } catch (ArgumentException e) { throw new ArgumentException(pawn + ".lifeStage[" + pawn.ageTracker.CurLifeStageIndex + "].bodyGraphicData", e); } return(Vector2.zero); } }
public static string GetLabel(PawnRenderer __instance) => $"{__instance.pawn.Label} - {__instance.pawn.ThingID}";
public static bool TryGetGraphicApparel(Apparel apparel, BodyTypeDef bodyType, out ApparelGraphicRecord rec) { if (bodyType == null) { Log.Error("Getting apparel graphic with undefined body type."); bodyType = BodyTypeDefOf.Male; } if (apparel.def.apparel.wornGraphicPath.NullOrEmpty()) { rec = new ApparelGraphicRecord(null, null); return(false); } string path = ((apparel.def.apparel.LastLayer != ApparelLayerDefOf.Overhead && !PawnRenderer.RenderAsPack(apparel) && !(apparel.def.apparel.wornGraphicPath == BaseContent.PlaceholderImagePath)) ? (apparel.def.apparel.wornGraphicPath + "_" + bodyType.defName) : apparel.def.apparel.wornGraphicPath); Shader shader = ShaderDatabase.Cutout; if (apparel.def.apparel.useWornGraphicMask) { shader = ShaderDatabase.CutoutComplex; } Graphic graphic = GraphicDatabase.Get <Graphic_Multi>(path, shader, apparel.def.graphicData.drawSize, apparel.DrawColor); rec = new ApparelGraphicRecord(graphic, apparel); return(true); }
//public static void DrawEquipmentAimingPostFix(PawnRenderer __instance, Thing eq, Vector3 drawLoc, float aimAngle) //{ // Pawn pawn = (Pawn)AccessTools.Field(typeof(PawnRenderer), "pawn").GetValue(__instance); // Pawn_EquipmentTracker pawn_EquipmentTracker = pawn.equipment; // if (pawn_EquipmentTracker != null) // { // ThingWithComps thingWithComps = (ThingWithComps)AccessTools.Field(typeof(Pawn_EquipmentTracker), "primaryInt").GetValue(pawn_EquipmentTracker); // if (thingWithComps != null) // { // CompOversizedWeapon compOversizedWeapon = thingWithComps.TryGetComp<CompOversizedWeapon>(); // if (compOversizedWeapon != null) // { // bool flip = false; // float num = aimAngle - 90f; // Mesh mesh; // if (aimAngle > 20f && aimAngle < 160f) // { // mesh = MeshPool.plane10; // num += eq.def.equippedAngleOffset; // } // else if (aimAngle > 200f && aimAngle < 340f) // { // mesh = MeshPool.plane10Flip; // flip = true; // num -= 180f; // num -= eq.def.equippedAngleOffset; // } // else // { // mesh = MeshPool.plane10; // num += eq.def.equippedAngleOffset; // } // num %= 360f; // Graphic_StackCount graphic_StackCount = eq.Graphic as Graphic_StackCount; // Material matSingle; // if (graphic_StackCount != null) // { // matSingle = graphic_StackCount.SubGraphicForStackCount(1, eq.def).MatSingle; // } // else // { // matSingle = eq.Graphic.MatSingle; // } // //mesh = MeshPool.GridPlane(thingWithComps.def.graphicData.drawSize); // //Graphics.DrawMesh(mesh, drawLoc, Quaternion.AngleAxis(num, Vector3.up), matSingle, 0); // //Log.Message("Oversized Draw"); // //Vector3 s = new Vector3(eq.def.graphicData.drawSize.x, 1f, eq.def.graphicData.drawSize.y); // //Matrix4x4 matrix = default(Matrix4x4); // //matrix.SetTRS(drawLoc, Quaternion.AngleAxis(num, Vector3.up), s); // //if (!flip) Graphics.DrawMesh(MeshPool.plane10, matrix, matSingle, 0); // //else Graphics.DrawMesh(MeshPool.plane10Flip, matrix, matSingle, 0); // //Log.Message("Oversized Called"); // } // } // } //} /// <summary> /// Adds another "layer" to the equipment aiming if they have a /// weapon with a CompActivatableEffect. /// </summary> /// <param name="__instance"></param> /// <param name="eq"></param> /// <param name="drawLoc"></param> /// <param name="aimAngle"></param> public static bool DrawEquipmentAimingPreFix(PawnRenderer __instance, Thing eq, Vector3 drawLoc, float aimAngle) { Pawn pawn = (Pawn)AccessTools.Field(typeof(PawnRenderer), "pawn").GetValue(__instance); Pawn_EquipmentTracker pawn_EquipmentTracker = pawn.equipment; if (pawn_EquipmentTracker != null) { ThingWithComps thingWithComps = (ThingWithComps)AccessTools.Field(typeof(Pawn_EquipmentTracker), "primaryInt").GetValue(pawn_EquipmentTracker); if (thingWithComps != null) { //If the deflector is active, it's already using this code. ThingComp deflector = thingWithComps.AllComps.FirstOrDefault <ThingComp>((ThingComp y) => y.GetType().ToString().Contains("Deflect")); if (deflector != null) { //Log.Message("Prefix"); bool isAnimatingNow = (bool)AccessTools.Property(deflector.GetType(), "IsAnimatingNow").GetValue(deflector, null); if (isAnimatingNow) { return(false); } } } CompOversizedWeapon compOversizedWeapon = thingWithComps.TryGetComp <CompOversizedWeapon>(); if (compOversizedWeapon != null) { bool flip = false; float num = aimAngle - 90f; Mesh mesh; if (aimAngle > 20f && aimAngle < 160f) { mesh = MeshPool.plane10; num += eq.def.equippedAngleOffset; } else if (aimAngle > 200f && aimAngle < 340f) { mesh = MeshPool.plane10Flip; flip = true; num -= 180f; num -= eq.def.equippedAngleOffset; } else { mesh = MeshPool.plane10; num += eq.def.equippedAngleOffset; } num %= 360f; Graphic_StackCount graphic_StackCount = eq.Graphic as Graphic_StackCount; Material matSingle; if (graphic_StackCount != null) { matSingle = graphic_StackCount.SubGraphicForStackCount(1, eq.def).MatSingle; } else { matSingle = eq.Graphic.MatSingle; } //mesh = MeshPool.GridPlane(thingWithComps.def.graphicData.drawSize); //Graphics.DrawMesh(mesh, drawLoc, Quaternion.AngleAxis(num, Vector3.up), matSingle, 0); //Log.Message("Oversized Draw"); Vector3 s = new Vector3(eq.def.graphicData.drawSize.x, 1f, eq.def.graphicData.drawSize.y); Matrix4x4 matrix = default(Matrix4x4); matrix.SetTRS(drawLoc, Quaternion.AngleAxis(num, Vector3.up), s); if (!flip) { Graphics.DrawMesh(MeshPool.plane10, matrix, matSingle, 0); } else { Graphics.DrawMesh(MeshPool.plane10Flip, matrix, matSingle, 0); } return(false); //Log.Message("Oversized Called"); } } 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) { Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); // bool selected = Find.Selector.SelectedObjects.Contains(pawn) && Prefs.DevMode; if (!portrait) { if (pawn.RaceProps.Humanlike && pawn.CurrentBed() != null && pawn.CurrentBed() is 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(); } } } } }
// Verse.PawnRenderer /// <summary> /// Render a character in a place. /// </summary> public static bool CutoffBody(PawnRenderer __instance, Vector3 rootLoc, Quaternion quat, bool renderBody, Rot4 bodyFacing, Rot4 headFacing, RotDrawMode bodyDrawType, bool portrait, bool headStump) { //Log.Message("1"); var Daniel = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); //Log.Message("2"); /////////////////////// Log.Message("Matthew teacher is wearing glassessssssssssssssss"); if (Daniel == null || !(Daniel.PositionHeld is IntVec3 vec) || !vec.IsValid || !(vec.GetTerrain(Daniel.MapHeld) is TerrainDef def)) { return(true); } //Log.Message("3"); try { if (!Find.TickManager.Paused) { //Log.Message("4"); DrowningCheck(Daniel, def); //j,hvkftyjdyfyfytetjyuhfdgtgvhjmb,nkjutvhrtrgtbhnmb,gu,j6yhdtgexwssr 5nhyj6ujhm,k.u,jhbyrhd4t3cy 7m6ki,l;kiu7yr5f43243rghy67ujklu;k'loi;i9hynt7g6rfvdcr4v3fr4tyu6i7kl8;9[p;kujhygtrfew2e45efr6ghbjnmkl,;.lkjnhgvf6cxd45fc6gv7bh8njukm0il,k0mjnhy8gvfr6gyvthyjuk0iujyhtgrvfcet5rgthyjukil,kujyhtgrvfecdwefrgyujnilmky애국가1.동해물과 백두산이 마르고 닳도록 하느님이 보우하 우리나라 만세 무궁화 삼천리 화려강산 대한사람 대한으로 길이 보전하세. //Log.Message("5"); } if (def.IsDeep()) { renderBody = false; if (!__instance.graphics.AllResolved) { __instance.graphics.ResolveAllGraphics(); } Mesh mesh = null; Vector3 vector = rootLoc; var a = rootLoc; if (bodyFacing != Rot4.North) { a.y += 0.0281250011f; vector.y += 0.0234375f; } else { a.y += 0.0234375f; vector.y += 0.0281250011f; } if (__instance.graphics.headGraphic != null) { var b = quat * __instance.BaseHeadOffsetAt(headFacing); var material = __instance.graphics.HeadMatAt(headFacing, bodyDrawType, headStump); if (material != null) { var mesh2 = MeshPool.humanlikeHeadSet.MeshAt(headFacing); GenDraw.DrawMeshNowOrLater(mesh2, a + b, quat, material, portrait); } var loc2 = rootLoc + b; loc2.y += 0.0328125022f; var flag = false; if (!portrait || !Prefs.HatsOnlyOnMap) { var mesh3 = __instance.graphics.HairMeshSet.MeshAt(headFacing); var apparelGraphics = __instance.graphics.apparelGraphics; for (var j = 0; j < apparelGraphics.Count; j++) { if (apparelGraphics[j].sourceApparel.def.apparel.LastLayer != ApparelLayer.Overhead) { continue; } flag = true; var material2 = apparelGraphics[j].graphic.MatAt(bodyFacing, null); material2 = __instance.graphics.flasher.GetDamagedMat(material2); GenDraw.DrawMeshNowOrLater(mesh3, loc2, quat, material2, portrait); } } if (!flag && bodyDrawType != RotDrawMode.Dessicated && !headStump) { var mesh4 = __instance.graphics.HairMeshSet.MeshAt(headFacing); var mat = __instance.graphics.HairMatAt(headFacing); GenDraw.DrawMeshNowOrLater(mesh4, loc2, quat, mat, portrait); } } if (!portrait && Daniel.RaceProps.Animal && Daniel.inventory != null && Daniel.inventory.innerContainer.Count > 0) { Graphics.DrawMesh(mesh, vector, quat, __instance.graphics.packGraphic.MatAt(Daniel.Rotation, null), 0); } if (!portrait && Daniel.RaceProps.Animal) { var req = new MaterialRequest (ContentFinder <Texture2D> .Get("WaterShadow")); Vector3 s = new Vector3(2.0f, 1f, 2.0f); Matrix4x4 matrix = default(Matrix4x4); matrix.SetTRS(vector, Quaternion.identity, s); Graphics.DrawMesh(MeshPool.plane10, matrix, MaterialPool.MatFrom(req), 0); } if (portrait) { return(false); } AccessTools.Method(typeof(PawnRenderer), "DrawEquipment") .Invoke(__instance, new object[] { rootLoc }); //__instance.DrawEquipment(rootLoc); if (Daniel.apparel != null) { var wornApparel = Daniel.apparel.WornApparel; for (var l = 0; l < wornApparel.Count; l++) { wornApparel[l].DrawWornExtras(); } } var bodyLoc = rootLoc; bodyLoc.y += 0.0421875f; var Tweety = Traverse.Create(__instance).Field("statusOverlays").GetValue <PawnHeadOverlays>(); Tweety.RenderStatusOverlays(bodyLoc, quat, MeshPool.humanlikeHeadSet.MeshAt(headFacing)); return(false); } } catch { } return(true); }
public static bool DrawEquipmentPrefix(PawnRenderer __instance, Pawn ___pawn, Vector3 rootLoc) { if (___pawn.Dead || !___pawn.Spawned) { return(false); } if (___pawn.equipment == null || ___pawn.equipment.Primary == null) { return(false); } if (___pawn.CurJob != null && ___pawn.CurJob.def.neverShowWeapon) { return(false); } Stance_Busy stance_Busy = ___pawn.stances.curStance as Stance_Busy; CompWeaponExtention compW = ___pawn.equipment.Primary.GetComp <CompWeaponExtention>(); CompSheath compSheath = ___pawn.equipment.Primary.GetComp <CompSheath>(); bool busy = (stance_Busy != null) && (!stance_Busy.neverAimWeapon) && (stance_Busy.focusTarg.IsValid); if (busy) { Vector3 drawLoc = rootLoc; Vector3 a; if (stance_Busy.focusTarg.HasThing) { a = stance_Busy.focusTarg.Thing.DrawPos; } else { a = stance_Busy.focusTarg.Cell.ToVector3Shifted(); } float num = 0f; if ((a - ___pawn.DrawPos).MagnitudeHorizontalSquared() > 0.001f) { num = (a - ___pawn.DrawPos).AngleFlat(); } if (compW != null && compW.littleDown) { drawLoc.z += littleDown; } drawLoc += new Vector3(0f, 0f, 0.4f).RotatedBy(num); drawLoc.y += drawYPosition; //DrawEquipmentAiming(___pawn.equipment.Primary, drawLoc, num); __instance.DrawEquipmentAiming(___pawn.equipment.Primary, drawLoc, num); if (compSheath != null) { DrawSheath(compSheath, ___pawn, rootLoc, compSheath.SheathOnlyGraphic); } return(false); } else if ((___pawn.carryTracker == null || ___pawn.carryTracker.CarriedThing == null) && (___pawn.Drafted || (___pawn.CurJob != null && ___pawn.CurJob.def.alwaysShowWeapon) || (___pawn.mindState.duty != null && ___pawn.mindState.duty.def.alwaysShowWeapon))) { Vector3 drawLoc = rootLoc; if (compW != null) { switch (___pawn.Rotation.AsInt) { case 0: drawLoc += compW.Props.northOffset.position; DrawEquipmentAiming(___pawn.equipment.Primary, drawLoc, compW.Props.northOffset.angle); break; case 1: drawLoc += compW.Props.eastOffset.position; drawLoc.y += drawYPosition; DrawEquipmentAiming(___pawn.equipment.Primary, drawLoc, compW.Props.eastOffset.angle); break; case 2: drawLoc += compW.Props.southOffset.position; drawLoc.y += drawYPosition; DrawEquipmentAiming(___pawn.equipment.Primary, drawLoc, compW.Props.southOffset.angle); break; case 3: drawLoc += compW.Props.westOffset.position; drawLoc.y += drawYPosition; DrawEquipmentAiming(___pawn.equipment.Primary, drawLoc, compW.Props.westOffset.angle); break; default: break; } } else { if (___pawn.Rotation == Rot4.South) { Vector3 drawLoc2 = rootLoc + new Vector3(0f, 0f, -0.22f); drawLoc2.y += drawYPosition; __instance.DrawEquipmentAiming(___pawn.equipment.Primary, drawLoc2, 143f); } else if (___pawn.Rotation == Rot4.North) { Vector3 drawLoc3 = rootLoc + new Vector3(0f, 0f, -0.11f); __instance.DrawEquipmentAiming(___pawn.equipment.Primary, drawLoc3, 143f); } else if (___pawn.Rotation == Rot4.East) { Vector3 drawLoc4 = rootLoc + new Vector3(0.2f, 0f, -0.22f); drawLoc4.y += drawYPosition; __instance.DrawEquipmentAiming(___pawn.equipment.Primary, drawLoc4, 143f); } else if (___pawn.Rotation == Rot4.West) { Vector3 drawLoc5 = rootLoc + new Vector3(-0.2f, 0f, -0.22f); drawLoc5.y += drawYPosition; __instance.DrawEquipmentAiming(___pawn.equipment.Primary, drawLoc5, 217f); } } if (compSheath != null) { DrawSheath(compSheath, ___pawn, rootLoc, compSheath.SheathOnlyGraphic); } return(false); } if (!(___pawn.InBed()) && ___pawn.GetPosture() == PawnPosture.Standing) { if (compSheath != null) { Log.Message Vector3 drawLoc = rootLoc; DrawSheath(compSheath, ___pawn, drawLoc, compSheath.FullGraphic); } } return(false); }
/// <summary> /// Adds another "layer" to the equipment aiming if they have a /// weapon with a CompActivatableEffect. /// </summary> /// <param name="__instance"></param> /// <param name="eq"></param> /// <param name="drawLoc"></param> /// <param name="aimAngle"></param> public static bool DrawEquipmentAimingPreFix(PawnRenderer __instance, Thing eq, Vector3 drawLoc, float aimAngle) { if (eq is ThingWithComps thingWithComps) { //If the deflector is active, it's already using this code. var deflector = thingWithComps.AllComps.FirstOrDefault(y => y.GetType().ToString() == "CompDeflector.CompDeflector" || y.GetType().BaseType.ToString() == "CompDeflector.CompDeflector"); if (deflector != null) { var isAnimatingNow = Traverse.Create(deflector).Property("IsAnimatingNow").GetValue <bool>(); if (isAnimatingNow) { return(false); } } var compOversizedWeapon = thingWithComps.TryGetComp <AdeptusMechanicus.CompOversizedWeapon>(); if (compOversizedWeapon != null) { var flip = false; var num = aimAngle - 90f; var pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); if (pawn == null) { return(true); } Mesh mesh; if (aimAngle > 20f && aimAngle < 160f) { mesh = MeshPool.plane10; num += eq.def.equippedAngleOffset; } else if (aimAngle > 200f && aimAngle < 340f) { mesh = MeshPool.plane10Flip; flip = true; num -= 180f; num -= eq.def.equippedAngleOffset; } else { num = AdjustOffsetAtPeace(eq, pawn, compOversizedWeapon, num); } if (compOversizedWeapon.Props != null && (!pawn.IsFighting() && (compOversizedWeapon.Props.verticalFlipNorth && pawn.Rotation == Rot4.North))) { num += 180f; } if (!pawn.IsFighting() || pawn.TargetCurrentlyAimingAt == null) { num = AdjustNonCombatRotation(pawn, num, compOversizedWeapon); } num %= 360f; var graphic_StackCount = eq.Graphic as Graphic_StackCount; Material matSingle; if (graphic_StackCount != null) { matSingle = graphic_StackCount.SubGraphicForStackCount(1, eq.def).MatSingle; } else { matSingle = eq.Graphic.MatSingle; } var s = new Vector3(eq.def.graphicData.drawSize.x, 1f, eq.def.graphicData.drawSize.y); var matrix = default(Matrix4x4); Vector3 curOffset = AdjustRenderOffsetFromDir(pawn, compOversizedWeapon); curOffset.y -= 0.1f; matrix.SetTRS(drawLoc + curOffset, Quaternion.AngleAxis(num, Vector3.up), s); Graphics.DrawMesh(!flip ? MeshPool.plane10 : MeshPool.plane10Flip, matrix, matSingle, 0); if (compOversizedWeapon.Props != null && compOversizedWeapon.Props.isDualWeapon) { curOffset = new Vector3(-1f * curOffset.x, curOffset.y, curOffset.z); Mesh curPool; if (pawn.Rotation == Rot4.North || pawn.Rotation == Rot4.South) { num += 135f; num %= 360f; curPool = !flip ? MeshPool.plane10Flip : MeshPool.plane10; } else { curOffset = new Vector3(curOffset.x, curOffset.y - 0.1f, curOffset.z + 0.15f); curPool = !flip ? MeshPool.plane10 : MeshPool.plane10Flip; } matrix.SetTRS(drawLoc + curOffset, Quaternion.AngleAxis(num, Vector3.up), s); Graphics.DrawMesh(curPool, matrix, matSingle, 0); } return(false); } } //} return(true); }
public override void SpawnSetup(Map map, bool respawningAfterLoad) { base.SpawnSetup(map, respawningAfterLoad); this.male_graphic = this.ageTracker.CurKindLifeStage.bodyGraphicData.texPath; bool female = false; if (this.ageTracker.CurKindLifeStage.femaleGraphicData != null) { this.female_graphic = this.ageTracker.CurKindLifeStage.femaleGraphicData.texPath; if (this.gender == Gender.Female) { female = true; } } this.pawn_renderer = ((Pawn_DrawTracker)typeof(Pawn).GetField("drawer", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this)).renderer; if (!this.TryLoadSkinSet()) { Log.Error("Couldn't find " + this.def.defName + "_SkinSet.xml! This file is required for animals using the variations framework."); } else { int curLifeStageIndex = this.ageTracker.CurLifeStageIndex; if (this.skin_index == -1) { if (base.Map.mapTemperature.OutdoorTemp < 0f) { this.winter_coat_timer = 50; } int new_skin = Rand.Range(0, this.num_skins(curLifeStageIndex, female) + 1); if (AnimalMultiSkins.skinset_xml != null && new_skin != 0) { int num = 100; float num2 = float.Parse(this.GetSkinValue(curLifeStageIndex, new_skin, "commonality", female)); while (num2 <= Rand.Value && num > 0) { new_skin = Rand.Range(0, this.num_skins(curLifeStageIndex, female) + 1); if (new_skin == 0) { num2 = 1f; } else { num2 = float.Parse(this.GetSkinValue(curLifeStageIndex, new_skin, "commonality", female)); } num--; } if (num == 0) { new_skin = 0; } } int num3 = (int)(float.Parse(this.GetSkinValue(curLifeStageIndex, new_skin, "commonality", female)) / (float)(this.num_skins(curLifeStageIndex, female) + 1) * 100f); Log.Message(string.Concat(new object[] { "Creating new ", this.gender.ToString().ToLower(), " ", this.def.defName, " with skin index of ", new_skin, " where ", this.num_skins(curLifeStageIndex, female), " possible variants were available. Chance was ", num3, "%." })); LongEventHandler.ExecuteWhenFinished(delegate { this.ApplyNewSkin(new_skin); }); this.last_age_stage = this.ageTracker.CurLifeStageIndex; } else { LongEventHandler.ExecuteWhenFinished(delegate { this.ApplyNewSkin(this.skin_index); }); } } }
static void Prefix(Pawn ___pawn, ref Thing eq, ref Vector3 drawLoc, ref float aimAngle, PawnRenderer __instance) { if (___pawn == null) { return; } IDrawnWeaponWithRotation gun = eq as IDrawnWeaponWithRotation; if (gun == null) { return; } Stance_Busy stance_Busy = ___pawn.stances.curStance as Stance_Busy; if (stance_Busy != null && !stance_Busy.neverAimWeapon && stance_Busy.focusTarg.IsValid) { drawLoc -= new Vector3(0f, 0f, 0.4f).RotatedBy(aimAngle); aimAngle = (aimAngle + gun.RotationOffset) % 360; drawLoc += new Vector3(0f, 0f, 0.4f).RotatedBy(aimAngle); } }
public static void DrawEquipmentAiming_Prefix(PawnRenderer __instance, Thing eq, Vector3 drawLoc, ref float aimAngle) { Pawn pawn = __instance.graphics.pawn; // Flip the angle for north if (pawn.Rotation == Rot4.North && aimAngle == angleStanding) { aimAngle = angleStandingFlipped; } if (!pawn.GetCompAnim(out CompBodyAnimator animator)) { return; } if (Find.TickManager.TicksGame == animator.LastAngleTick) { aimAngle = animator.LastAimAngle; return; } animator.LastAngleTick = Find.TickManager.TicksGame; float angleChange; float startAngle = animator.LastAimAngle; float endAngle = aimAngle; FloatTween tween = animator.AimAngleTween; switch (tween.State) { case TweenState.Running: startAngle = tween.EndValue; endAngle = aimAngle; aimAngle = tween.CurrentValue; break; } angleChange = CalcShortestRot(startAngle, endAngle); if (Mathf.Abs(angleChange) > 6f) { // no tween for flipping bool x = Mathf.Abs(animator.LastAimAngle - angleStanding) < 3f && Mathf.Abs(aimAngle - angleStandingFlipped) < 3f; bool y = Mathf.Abs(animator.LastAimAngle - angleStandingFlipped) < 3f && Mathf.Abs(aimAngle - angleStanding) < 3f; bool z = Math.Abs(Mathf.Abs(aimAngle - animator.LastAimAngle) - 180f) < 12f; if (!x && !y && !z) { // if (Math.Abs(aimAngleTween.EndValue - weaponAngle) > 6f) tween.Start(startAngle, startAngle + angleChange, Mathf.Abs(angleChange), ScaleFuncs.QuinticEaseOut); aimAngle = startAngle; } } animator.LastAimAngle = aimAngle; }
/* * static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) * { * var instructionsList = new List<CodeInstruction>(instructions); * foreach (CodeInstruction instruction in instructionsList) * { * if (instruction.operand == typeof(PawnRenderer).GetMethod("DrawEquipmentAiming")) * { * yield return new CodeInstruction(OpCodes.Call, typeof(PawnRenderer_DrawEquipment).GetMethod("DrawEquipmentAimingModified")); * } * else * { * yield return instruction; * } * } * } */ static bool Prefix(PawnRenderer __instance, Thing eq, ref Vector3 drawLoc, ref float aimAngle, ref Pawn ___pawn) { ThingWithComps offHandEquip = null; if (___pawn.equipment == null) { return(true); } if (___pawn.equipment.TryGetOffHandEquipment(out ThingWithComps result)) { offHandEquip = result; } if (offHandEquip == null) { return(true); } float mainHandAngle = aimAngle; float offHandAngle = aimAngle; Stance_Busy mainStance = ___pawn.stances.curStance as Stance_Busy; Stance_Busy offHandStance = null; if (___pawn.GetStancesOffHand() != null) { offHandStance = ___pawn.GetStancesOffHand().curStance as Stance_Busy; } LocalTargetInfo focusTarg = null; if (mainStance != null && !mainStance.neverAimWeapon) { focusTarg = mainStance.focusTarg; } else if (offHandStance != null && !offHandStance.neverAimWeapon) { focusTarg = offHandStance.focusTarg; } bool mainHandAiming = CurrentlyAiming(mainStance); bool offHandAiming = CurrentlyAiming(offHandStance); Vector3 offsetMainHand = new Vector3(); Vector3 offsetOffHand = new Vector3(); //bool currentlyAiming = (mainStance != null && !mainStance.neverAimWeapon && mainStance.focusTarg.IsValid) || stancesOffHand.curStance is Stance_Busy ohs && !ohs.neverAimWeapon && ohs.focusTarg.IsValid; //When wielding offhand weapon, facing south, and not aiming, draw differently SetAnglesAndOffsets(eq, offHandEquip, aimAngle, ___pawn, ref offsetMainHand, ref offsetOffHand, ref mainHandAngle, ref offHandAngle, mainHandAiming, offHandAiming); if (offHandEquip != ___pawn.equipment.Primary) { //drawLoc += offsetMainHand; //aimAngle = mainHandAngle; //__instance.DrawEquipmentAiming(eq, drawLoc + offsetMainHand, mainHandAngle); DrawEquipmentAimingOverride(eq, drawLoc + offsetMainHand, mainHandAngle); } if ((offHandAiming || mainHandAiming) && focusTarg != null) { offHandAngle = GetAimingRotation(___pawn, focusTarg); offsetOffHand.y += 0.1f; Vector3 adjustedDrawPos = ___pawn.DrawPos + new Vector3(0f, 0f, 0.4f).RotatedBy(offHandAngle) + offsetOffHand; DrawEquipmentAimingOverride(offHandEquip, adjustedDrawPos, offHandAngle); } else { DrawEquipmentAimingOverride(offHandEquip, drawLoc + offsetOffHand, offHandAngle); } return(false); }
public static void Listener(ref PawnRenderer __instance, Vector3 rootLoc, float angle, bool renderBody, Rot4 bodyFacing, Rot4 headFacing, RotDrawMode bodyDrawType, bool portrait, bool headStump, bool invisible, Pawn ___pawn) { try { bool state = false; CompAndroidState cas = null; if (___pawn != null) { cas = ___pawn.ATCompState; } if (___pawn != null && (___pawn.def.defName == Utils.TX2 || ___pawn.def.defName == Utils.TX2I || ___pawn.def.defName == Utils.TX2KI || ___pawn.def.defName == Utils.TX3I || ___pawn.def.defName == Utils.TX4I || (___pawn.def.defName == Utils.TX2K && (cas.TXHurtedHeadSet || cas.TXHurtedHeadSet2)) || (___pawn.def.defName == Utils.TX3 && (cas.TXHurtedHeadSet || cas.TXHurtedHeadSet2)) || (___pawn.def.defName == Utils.TX4 && (cas.TXHurtedHeadSet || cas.TXHurtedHeadSet2))) && !___pawn.Dead && !headStump) { if (!portrait) { if (___pawn != null) { Pawn_JobTracker jobs = ___pawn.jobs; if ((((jobs != null) ? jobs.curDriver : null) != null)) { state = !___pawn.jobs.curDriver.asleep; } } } else { state = portrait; } } if (state) { Quaternion quaternion = Quaternion.AngleAxis(angle, Vector3.up); Vector3 a = rootLoc; if (bodyFacing != Rot4.North) { a.y += 0.0281250011f; rootLoc.y += 0.0234375f; } else { a.y += 0.0234375f; rootLoc.y += 0.0281250011f; } Vector3 b = quaternion * __instance.BaseHeadOffsetAt(headFacing); Vector3 loc = a + b + new Vector3(0f, 0.01f, 0f); if (headFacing != Rot4.North) { Mesh mesh = MeshPool.humanlikeHeadSet.MeshAt(headFacing); bool isHorizontal = headFacing.IsHorizontal; int type = 1; if (cas.TXHurtedHeadSet) { type = 2; } else if (cas.TXHurtedHeadSet2 || ___pawn.def.defName == Utils.TX2I || ___pawn.def.defName == Utils.TX2KI || ___pawn.def.defName == Utils.TX3I || ___pawn.def.defName == Utils.TX4I) { type = 3; } //Couleur yeux standard TX2 Color color = new Color(0.9450f, 0.76862f, 0.05882f); //Couleur yeux TX3/TX4 standard (bleu cyan) if (___pawn.def.defName == Utils.TX3 || ___pawn.def.defName == Utils.TX4 || ___pawn.def.defName == Utils.TX3I || ___pawn.def.defName == Utils.TX4I) { color = new Color(0f, 0.972549f, 0.972549f); } // yeux rouges si drafté OU ennemis OU TX2K if (___pawn.Drafted || (___pawn.Faction != null && ___pawn.Faction.HostileTo(Faction.OfPlayer)) || ___pawn.def.defName == Utils.TX2K || ___pawn.def.defName == Utils.TX2KI) { color = new Color(0.75f, 0f, 0f, 1f); } string gender = "M"; if (___pawn.gender == Gender.Female) { gender = "F"; } if (isHorizontal) { GenDraw.DrawMeshNowOrLater(mesh, loc, quaternion, Tex.getEyeGlowEffect(color, gender, type, 0).MatSingle, portrait); } else { GenDraw.DrawMeshNowOrLater(mesh, loc, quaternion, Tex.getEyeGlowEffect(color, gender, type, 1).MatSingle, portrait); } } } } catch (Exception e) { Log.Message("[ATPP] PawnRenderer.RenderPawnInternal " + e.Message + " " + e.StackTrace); } }
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; string direction = ""; float offset = 0f; 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); bool OffsetDefExtension = (pawn.def.modExtensions.NullOrEmpty() || (!pawn.def.modExtensions.NullOrEmpty() && pawn.def.modExtensions.Any((x) => comp.parent.def.defName.Contains(((OffsetDefExtension)x).hediff.defName))) || ThingDefOf.Human.modExtensions.Any((x) => comp.parent.def.defName.Contains(((OffsetDefExtension)x).hediff.defName))); if (OffsetDefExtension)// && pawn.kindDef.race.GetModExtension<OffsetDefExtension>() is OffsetDefExtension offsetDef && comp.parent.def.defName.Contains(offsetDef.hediff.defName)) { 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 // 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); } /* * 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); */ }
// Token: 0x0600000A RID: 10 RVA: 0x000022B0 File Offset: 0x000004B0 public static bool DrawEquipmentAimingPreFix(PawnRenderer __instance, Thing eq, Vector3 drawLoc, float aimAngle) { ThingWithComps thingWithComps = eq as ThingWithComps; bool flag = thingWithComps != null; if (flag) { ThingComp thingComp = thingWithComps.AllComps.FirstOrDefault((ThingComp y) => y.GetType().ToString() == "CompDeflector.CompDeflector" || y.GetType().BaseType.ToString() == "CompDeflector.CompDeflector"); bool flag2 = thingComp != null; if (flag2) { bool value = Traverse.Create(thingComp).Property("IsAnimatingNow", null).GetValue <bool>(); bool flag3 = value; if (flag3) { return(false); } } CompOversizedWeapon compOversizedWeapon = thingWithComps.TryGetComp <CompOversizedWeapon>(); bool flag4 = compOversizedWeapon != null; if (flag4) { bool flag5 = false; float num = aimAngle - 90f; Pawn value2 = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>(); bool flag6 = value2 == null; if (flag6) { return(true); } bool flag7 = aimAngle > 20f && aimAngle < 160f; if (flag7) { Mesh mesh = MeshPool.plane10; num += eq.def.equippedAngleOffset; } else { bool flag8 = aimAngle > 200f && aimAngle < 340f; if (flag8) { Mesh mesh = MeshPool.plane10Flip; flag5 = true; num -= 180f; num -= eq.def.equippedAngleOffset; } else { num = HarmonyCompOversizedWeapon.AdjustOffsetAtPeace(eq, value2, compOversizedWeapon, num); } } bool flag9 = compOversizedWeapon.Props != null && !value2.IsFighting() && compOversizedWeapon.Props.verticalFlipNorth && value2.Rotation == Rot4.North; if (flag9) { num += 180f; } bool flag10 = !value2.IsFighting(); if (flag10) { num = HarmonyCompOversizedWeapon.AdjustNonCombatRotation(value2, num, compOversizedWeapon); } num %= 360f; Graphic_StackCount graphic_StackCount = eq.Graphic as Graphic_StackCount; bool flag11 = graphic_StackCount != null; Material matSingle; if (flag11) { matSingle = graphic_StackCount.SubGraphicForStackCount(1, eq.def).MatSingle; } else { matSingle = eq.Graphic.MatSingle; } Vector3 vector = new Vector3(eq.def.graphicData.drawSize.x, 1f, eq.def.graphicData.drawSize.y); Matrix4x4 matrix4x = default(Matrix4x4); Vector3 vector2 = HarmonyCompOversizedWeapon.AdjustRenderOffsetFromDir(value2, compOversizedWeapon); matrix4x.SetTRS(drawLoc + vector2, Quaternion.AngleAxis(num, Vector3.up), vector); Graphics.DrawMesh((!flag5) ? MeshPool.plane10 : MeshPool.plane10Flip, matrix4x, matSingle, 0); bool flag12 = compOversizedWeapon.Props != null && compOversizedWeapon.Props.isDualWeapon; if (flag12) { vector2 = new Vector3(-1f * vector2.x, vector2.y, vector2.z); bool flag13 = value2.Rotation == Rot4.North || value2.Rotation == Rot4.South; Mesh mesh2; if (flag13) { num += 135f; num %= 360f; mesh2 = ((!flag5) ? MeshPool.plane10Flip : MeshPool.plane10); } else { vector2 = new Vector3(vector2.x, vector2.y - 0.1f, vector2.z + 0.15f); mesh2 = ((!flag5) ? MeshPool.plane10 : MeshPool.plane10Flip); } matrix4x.SetTRS(drawLoc + vector2, Quaternion.AngleAxis(num, Vector3.up), vector); Graphics.DrawMesh(mesh2, matrix4x, matSingle, 0); } return(false); } } return(true); }
public static string GetName(PawnRenderer __instance) => __instance.pawn.GetHashCode().ToString();
///// <summary> ///// Prevents the user from having damage with the verb. ///// </summary> ///// <param name="__instance"></param> ///// <param name="__result"></param> ///// <param name="pawn"></param> //public static void GetDamageFactorForPostFix(Verb __instance, ref float __result, Pawn pawn) //{ // Pawn_EquipmentTracker pawn_EquipmentTracker = pawn.equipment; // if (pawn_EquipmentTracker != null) // { // //Log.Message("2"); // ThingWithComps thingWithComps = (ThingWithComps)AccessTools.Field(typeof(Pawn_EquipmentTracker), "primaryInt").GetValue(pawn_EquipmentTracker); // if (thingWithComps != null) // { // //Log.Message("3"); // CompActivatableEffect compActivatableEffect = thingWithComps.GetComp<CompActivatableEffect>(); // if (compActivatableEffect != null) // { // if (compActivatableEffect.CurrentState != CompActivatableEffect.State.Activated) // { // //Messages.Message("DeactivatedWarning".Translate(), MessageSound.RejectInput); // __result = 0f; // } // } // } // } //} /// <summary> /// Adds another "layer" to the equipment aiming if they have a /// weapon with a CompActivatableEffect. /// </summary> /// <param name="__instance"></param> /// <param name="eq"></param> /// <param name="drawLoc"></param> /// <param name="aimAngle"></param> public static void DrawEquipmentAimingPostFix(PawnRenderer __instance, Thing eq, Vector3 drawLoc, float aimAngle) { var pawn = (Pawn)AccessTools.Field(typeof(PawnRenderer), "pawn").GetValue(__instance); var pawn_EquipmentTracker = pawn.equipment; if (pawn_EquipmentTracker != null) { //Log.Message("2"); //ThingWithComps thingWithComps = (ThingWithComps)AccessTools.Field(typeof(Pawn_EquipmentTracker), "primaryInt").GetValue(pawn_EquipmentTracker); var thingWithComps = pawn_EquipmentTracker .Primary; //(ThingWithComps)AccessTools.Field(typeof(Pawn_EquipmentTracker), "primaryInt").GetValue(pawn_EquipmentTracker); if (thingWithComps != null) { //Log.Message("3"); var compActivatableEffect = thingWithComps.GetComp <CompActivatableEffect>(); if (compActivatableEffect != null) { if (compActivatableEffect.Graphic != null) { if (compActivatableEffect.CurrentState == CompActivatableEffect.State.Activated) { var num = aimAngle - 90f; var flip = false; if (aimAngle > 20f && aimAngle < 160f) { //mesh = MeshPool.GridPlaneFlip(thingWithComps.def.graphicData.drawSize); num += eq.def.equippedAngleOffset; } else if (aimAngle > 200f && aimAngle < 340f) { //mesh = MeshPool.GridPlane(thingWithComps.def.graphicData.drawSize); flip = true; num -= 180f; num -= eq.def.equippedAngleOffset; } else { //mesh = MeshPool.GridPlaneFlip(thingWithComps.def.graphicData.drawSize); num += eq.def.equippedAngleOffset; } if (eq is ThingWithComps eqComps) { var deflector = eqComps.AllComps.FirstOrDefault(y => y.GetType().ToString().Contains("Deflect")); if (deflector != null) { var isActive = (bool)AccessTools .Property(deflector.GetType(), "IsAnimatingNow").GetValue(deflector, null); if (isActive) { float numMod = (int)AccessTools .Property(deflector.GetType(), "AnimationDeflectionTicks") .GetValue(deflector, null); //float numMod2 = new float(); //numMod2 = numMod; if (numMod > 0) { if (!flip) { num += (numMod + 1) / 2; } else { num -= (numMod + 1) / 2; } } } } } num %= 360f; //ThingWithComps eqComps = eq as ThingWithComps; //if (eqComps != null) //{ // ThingComp deflector = eqComps.AllComps.FirstOrDefault<ThingComp>((ThingComp y) => y.GetType().ToString() == "CompDeflector.CompDeflector"); // if (deflector != null) // { // float numMod = (float)((int)AccessTools.Property(deflector.GetType(), "AnimationDeflectionTicks").GetValue(deflector, null)); // //Log.ErrorOnce("NumMod " + numMod.ToString(), 1239); //numMod = (numMod + 1) / 2; //if (subtract) num -= numMod; //else num += numMod; // } //} var matSingle = compActivatableEffect.Graphic.MatSingle; //if (mesh == null) mesh = MeshPool.GridPlane(thingWithComps.def.graphicData.drawSize); var s = new Vector3(eq.def.graphicData.drawSize.x, 1f, eq.def.graphicData.drawSize.y); var matrix = default(Matrix4x4); matrix.SetTRS(drawLoc, Quaternion.AngleAxis(num, Vector3.up), s); if (!flip) { Graphics.DrawMesh(MeshPool.plane10, matrix, matSingle, 0); } else { Graphics.DrawMesh(MeshPool.plane10Flip, matrix, matSingle, 0); } //Graphics.DrawMesh(mesh, drawLoc, Quaternion.AngleAxis(num, Vector3.up), matSingle, 0); } } } } } }