mirror of
				https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
				synced 2024-08-15 00:43:45 +00:00 
			
		
		
		
	removed HAR as a dependency
This commit is contained in:
		
							parent
							
								
									17e7fb1374
								
							
						
					
					
						commit
						d0a217ad12
					
				
					 3 changed files with 174 additions and 177 deletions
				
			
		
										
											Binary file not shown.
										
									
								
							| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
using HarmonyLib;
 | 
					/*using HarmonyLib;
 | 
				
			||||||
using System;
 | 
					using System;
 | 
				
			||||||
using System.Collections.Generic;
 | 
					using System.Collections.Generic;
 | 
				
			||||||
using System.Linq;
 | 
					using System.Linq;
 | 
				
			||||||
| 
						 | 
					@ -47,7 +47,7 @@ namespace Rimworld_Animations {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
		*/
 | 
							
 | 
				
			||||||
		public static bool Prefix_AnimateHeadAddons(PawnRenderFlags renderFlags, Vector3 vector, Vector3 headOffset, Pawn pawn, Quaternion quat, Rot4 rotation)
 | 
							public static bool Prefix_AnimateHeadAddons(PawnRenderFlags renderFlags, Vector3 vector, Vector3 headOffset, Pawn pawn, Quaternion quat, Rot4 rotation)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -143,215 +143,216 @@ namespace Rimworld_Animations {
 | 
				
			||||||
			return true;
 | 
								return true;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
					[HarmonyPatch(typeof(AlienRace.HarmonyPatches), "DrawAddons")]
 | 
				
			||||||
 | 
					public static class HarmonyPatch_AlienRace {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [HarmonyPatch(typeof(AlienRace.HarmonyPatches), "DrawAddons")]
 | 
						public static void RenderHeadAddonInAnimation(Mesh mesh, Vector3 loc, Quaternion quat, Material mat, bool drawNow, Graphic graphic, AlienPartGenerator.BodyAddon bodyAddon, Vector3 v, Vector3 headOffset, Pawn pawn, PawnRenderFlags renderFlags, Vector3 vector, Rot4 rotation)
 | 
				
			||||||
    public static class HarmonyPatch_AlienRace {
 | 
						{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		public static void RenderHeadAddonInAnimation(Mesh mesh, Vector3 loc, Quaternion quat, Material mat, bool drawNow, Graphic graphic, AlienPartGenerator.BodyAddon bodyAddon, Vector3 v, Vector3 headOffset, Pawn pawn, PawnRenderFlags renderFlags, Vector3 vector, Rot4 rotation)
 | 
							CompBodyAnimator pawnAnimator = pawn.TryGetComp<CompBodyAnimator>();
 | 
				
			||||||
        {
 | 
							AlienPartGenerator.AlienComp comp = pawn.GetComp<AlienPartGenerator.AlienComp>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			CompBodyAnimator pawnAnimator = pawn.TryGetComp<CompBodyAnimator>();
 | 
							if (pawnAnimator != null && pawnAnimator.isAnimating)
 | 
				
			||||||
			AlienPartGenerator.AlienComp comp = pawn.GetComp<AlienPartGenerator.AlienComp>();
 | 
							{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (pawnAnimator != null && pawnAnimator.isAnimating)
 | 
								if((bodyAddon.drawnInBed || bodyAddon.alignWithHead))
 | 
				
			||||||
            {
 | 
								{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if((bodyAddon.drawnInBed || bodyAddon.alignWithHead))
 | 
									AlienPartGenerator.RotationOffset offset = bodyAddon.defaultOffsets.GetOffset(rotation);
 | 
				
			||||||
                {
 | 
									Vector3 a = (offset != null) ? offset.GetOffset(renderFlags.FlagSet(PawnRenderFlags.Portrait), pawn.story.bodyType, comp.crownType) : Vector3.zero;
 | 
				
			||||||
					
 | 
									AlienPartGenerator.RotationOffset offset2 = bodyAddon.offsets.GetOffset(rotation);
 | 
				
			||||||
					AlienPartGenerator.RotationOffset offset = bodyAddon.defaultOffsets.GetOffset(rotation);
 | 
									Vector3 vector2 = a + ((offset2 != null) ? offset2.GetOffset(renderFlags.FlagSet(PawnRenderFlags.Portrait), pawn.story.bodyType, comp.crownType) : Vector3.zero);
 | 
				
			||||||
					Vector3 a = (offset != null) ? offset.GetOffset(renderFlags.FlagSet(PawnRenderFlags.Portrait), pawn.story.bodyType, comp.crownType) : Vector3.zero;
 | 
									vector2.y = (bodyAddon.inFrontOfBody ? (0.3f + vector2.y) : (-0.3f - vector2.y));
 | 
				
			||||||
					AlienPartGenerator.RotationOffset offset2 = bodyAddon.offsets.GetOffset(rotation);
 | 
									float num = bodyAddon.angle;
 | 
				
			||||||
					Vector3 vector2 = a + ((offset2 != null) ? offset2.GetOffset(renderFlags.FlagSet(PawnRenderFlags.Portrait), pawn.story.bodyType, comp.crownType) : Vector3.zero);
 | 
									if (rotation == Rot4.North)
 | 
				
			||||||
					vector2.y = (bodyAddon.inFrontOfBody ? (0.3f + vector2.y) : (-0.3f - vector2.y));
 | 
									{
 | 
				
			||||||
					float num = bodyAddon.angle;
 | 
										if (bodyAddon.layerInvert)
 | 
				
			||||||
					if (rotation == Rot4.North)
 | 
					 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						if (bodyAddon.layerInvert)
 | 
											vector2.y = -vector2.y;
 | 
				
			||||||
						{
 | 
					 | 
				
			||||||
							vector2.y = -vector2.y;
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
						num = 0f;
 | 
					 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
					if (rotation == Rot4.East)
 | 
										num = 0f;
 | 
				
			||||||
					{
 | 
					 | 
				
			||||||
						num = -num;
 | 
					 | 
				
			||||||
						vector2.x = -vector2.x;
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					vector = vector + Quaternion.AngleAxis(pawnAnimator.bodyAngle, Vector3.up) * pawn.Drawer.renderer.BaseHeadOffsetAt(pawnAnimator.bodyFacing) - pawnAnimator.getPawnHeadOffset(); //convert vector into pseudo body pos for head
 | 
					 | 
				
			||||||
					quat = Quaternion.AngleAxis(pawnAnimator.headAngle, Vector3.up);
 | 
					 | 
				
			||||||
					loc = vector + (bodyAddon.alignWithHead ? headOffset : Vector3.zero) + vector2.RotatedBy(Mathf.Acos(Quaternion.Dot(Quaternion.identity, quat)) * 2f * 57.29578f);
 | 
					 | 
				
			||||||
					mat = graphic.MatAt(rot: pawnAnimator.headFacing);
 | 
					 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				else
 | 
									if (rotation == Rot4.East)
 | 
				
			||||||
                {
 | 
									{
 | 
				
			||||||
 | 
										num = -num;
 | 
				
			||||||
					AlienPartGenerator.RotationOffset offset = bodyAddon.defaultOffsets.GetOffset(rotation);
 | 
										vector2.x = -vector2.x;
 | 
				
			||||||
					Vector3 a = (offset != null) ? offset.GetOffset(renderFlags.FlagSet(PawnRenderFlags.Portrait), pawn.story.bodyType, comp.crownType) : Vector3.zero;
 | 
					 | 
				
			||||||
					AlienPartGenerator.RotationOffset offset2 = bodyAddon.offsets.GetOffset(rotation);
 | 
					 | 
				
			||||||
					Vector3 vector2 = a + ((offset2 != null) ? offset2.GetOffset(renderFlags.FlagSet(PawnRenderFlags.Portrait), pawn.story.bodyType, comp.crownType) : Vector3.zero);
 | 
					 | 
				
			||||||
					vector2.y = (bodyAddon.inFrontOfBody ? (0.3f + vector2.y) : (-0.3f - vector2.y));
 | 
					 | 
				
			||||||
					float num = bodyAddon.angle;
 | 
					 | 
				
			||||||
					if (rotation == Rot4.North)
 | 
					 | 
				
			||||||
					{
 | 
					 | 
				
			||||||
						if (bodyAddon.layerInvert)
 | 
					 | 
				
			||||||
						{
 | 
					 | 
				
			||||||
							vector2.y = -vector2.y;
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
						num = 0f;
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
					if (rotation == Rot4.East)
 | 
					 | 
				
			||||||
					{
 | 
					 | 
				
			||||||
						num = -num;
 | 
					 | 
				
			||||||
						vector2.x = -vector2.x;
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
					quat = Quaternion.AngleAxis(pawnAnimator.bodyAngle, Vector3.up);
 | 
					 | 
				
			||||||
					loc = vector + (bodyAddon.alignWithHead ? headOffset : Vector3.zero) + vector2.RotatedBy(Mathf.Acos(Quaternion.Dot(Quaternion.identity, quat)) * 2f * 57.29578f);
 | 
					 | 
				
			||||||
					
 | 
					 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									vector = vector + Quaternion.AngleAxis(pawnAnimator.bodyAngle, Vector3.up) * pawn.Drawer.renderer.BaseHeadOffsetAt(pawnAnimator.bodyFacing) - pawnAnimator.getPawnHeadOffset(); //convert vector into pseudo body pos for head
 | 
				
			||||||
 | 
									quat = Quaternion.AngleAxis(pawnAnimator.headAngle, Vector3.up);
 | 
				
			||||||
 | 
									loc = vector + (bodyAddon.alignWithHead ? headOffset : Vector3.zero) + vector2.RotatedBy(Mathf.Acos(Quaternion.Dot(Quaternion.identity, quat)) * 2f * 57.29578f);
 | 
				
			||||||
 | 
									mat = graphic.MatAt(rot: pawnAnimator.headFacing);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									AlienPartGenerator.RotationOffset offset = bodyAddon.defaultOffsets.GetOffset(rotation);
 | 
				
			||||||
 | 
									Vector3 a = (offset != null) ? offset.GetOffset(renderFlags.FlagSet(PawnRenderFlags.Portrait), pawn.story.bodyType, comp.crownType) : Vector3.zero;
 | 
				
			||||||
 | 
									AlienPartGenerator.RotationOffset offset2 = bodyAddon.offsets.GetOffset(rotation);
 | 
				
			||||||
 | 
									Vector3 vector2 = a + ((offset2 != null) ? offset2.GetOffset(renderFlags.FlagSet(PawnRenderFlags.Portrait), pawn.story.bodyType, comp.crownType) : Vector3.zero);
 | 
				
			||||||
 | 
									vector2.y = (bodyAddon.inFrontOfBody ? (0.3f + vector2.y) : (-0.3f - vector2.y));
 | 
				
			||||||
 | 
									float num = bodyAddon.angle;
 | 
				
			||||||
 | 
									if (rotation == Rot4.North)
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										if (bodyAddon.layerInvert)
 | 
				
			||||||
 | 
										{
 | 
				
			||||||
 | 
											vector2.y = -vector2.y;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										num = 0f;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									if (rotation == Rot4.East)
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										num = -num;
 | 
				
			||||||
 | 
										vector2.x = -vector2.x;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									quat = Quaternion.AngleAxis(pawnAnimator.bodyAngle, Vector3.up);
 | 
				
			||||||
 | 
									loc = vector + (bodyAddon.alignWithHead ? headOffset : Vector3.zero) + vector2.RotatedBy(Mathf.Acos(Quaternion.Dot(Quaternion.identity, quat)) * 2f * 57.29578f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			GenDraw.DrawMeshNowOrLater(mesh, loc, quat, mat, drawNow);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			/*
 | 
							}
 | 
				
			||||||
			if (pawnAnimator != null && !renderFlags.FlagSet(PawnRenderFlags.Portrait) && pawnAnimator.isAnimating && (bodyAddon.drawnInBed || bodyAddon.alignWithHead))
 | 
							GenDraw.DrawMeshNowOrLater(mesh, loc, quat, mat, drawNow);
 | 
				
			||||||
            {
 | 
					
 | 
				
			||||||
 | 
							/*
 | 
				
			||||||
 | 
							if (pawnAnimator != null && !renderFlags.FlagSet(PawnRenderFlags.Portrait) && pawnAnimator.isAnimating && (bodyAddon.drawnInBed || bodyAddon.alignWithHead))
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if ((pawn.def as ThingDef_AlienRace).defName == "Alien_Orassan")
 | 
								if ((pawn.def as ThingDef_AlienRace).defName == "Alien_Orassan")
 | 
				
			||||||
                {
 | 
								{
 | 
				
			||||||
 | 
									orassan = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if(bodyAddon.path.Contains("closed"))
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										return;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									if (bodyAddon.bodyPart.Contains("ear"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
					orassan = true;
 | 
										orassan = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					if(bodyAddon.path.Contains("closed"))
 | 
										orassanv = new Vector3(0, 0, 0.23f);
 | 
				
			||||||
                    {
 | 
										if (pawnAnimator.headFacing == Rot4.North)
 | 
				
			||||||
						return;
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					if (bodyAddon.bodyPart.Contains("ear"))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					{
 | 
										{
 | 
				
			||||||
						orassan = true;
 | 
											orassanv.z -= 0.1f;
 | 
				
			||||||
 | 
											orassanv.y += 1f;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
						orassanv = new Vector3(0, 0, 0.23f);
 | 
											if(bodyAddon.bodyPart.Contains("left"))
 | 
				
			||||||
						if (pawnAnimator.headFacing == Rot4.North)
 | 
					 | 
				
			||||||
						{
 | 
											{
 | 
				
			||||||
							orassanv.z -= 0.1f;
 | 
												orassanv.x += 0.03f;
 | 
				
			||||||
							orassanv.y += 1f;
 | 
											} else
 | 
				
			||||||
 | 
											{
 | 
				
			||||||
							if(bodyAddon.bodyPart.Contains("left"))
 | 
												orassanv.x -= 0.03f;
 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
								orassanv.x += 0.03f;
 | 
					 | 
				
			||||||
                            } else
 | 
					 | 
				
			||||||
                            {
 | 
					 | 
				
			||||||
								orassanv.x -= 0.03f;
 | 
					 | 
				
			||||||
							}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
						else if (pawnAnimator.headFacing == Rot4.East)
 | 
					
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										else if (pawnAnimator.headFacing == Rot4.East)
 | 
				
			||||||
 | 
										{
 | 
				
			||||||
 | 
											orassanv.x -= 0.1f;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										else if (pawnAnimator.headFacing == Rot4.West)
 | 
				
			||||||
 | 
										{
 | 
				
			||||||
 | 
											orassanv.x = 0.1f;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
										else
 | 
				
			||||||
 | 
										{
 | 
				
			||||||
 | 
											orassanv.z -= 0.1f;
 | 
				
			||||||
 | 
											orassanv.y += 1f;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											if (bodyAddon.bodyPart.Contains("right"))
 | 
				
			||||||
						{
 | 
											{
 | 
				
			||||||
							orassanv.x -= 0.1f;
 | 
												orassanv.x += 0.05f;
 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
						else if (pawnAnimator.headFacing == Rot4.West)
 | 
					 | 
				
			||||||
						{
 | 
					 | 
				
			||||||
							orassanv.x = 0.1f;
 | 
					 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
						else
 | 
											else
 | 
				
			||||||
                        {
 | 
											{
 | 
				
			||||||
							orassanv.z -= 0.1f;
 | 
												orassanv.x -= 0.05f;
 | 
				
			||||||
							orassanv.y += 1f;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
							if (bodyAddon.bodyPart.Contains("right"))
 | 
					 | 
				
			||||||
							{
 | 
					 | 
				
			||||||
								orassanv.x += 0.05f;
 | 
					 | 
				
			||||||
							}
 | 
					 | 
				
			||||||
							else
 | 
					 | 
				
			||||||
							{
 | 
					 | 
				
			||||||
								orassanv.x -= 0.05f;
 | 
					 | 
				
			||||||
							}
 | 
					 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
						orassanv = orassanv.RotatedBy(pawnAnimator.headAngle);
 | 
					 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
 | 
										orassanv = orassanv.RotatedBy(pawnAnimator.headAngle);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
					
 | 
					 | 
				
			||||||
					
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			GenDraw.DrawMeshNowOrLater(mesh: graphic.MeshAt(rot: headRotInAnimation), loc: loc + orassanv + (bodyAddon.alignWithHead ? headOffset : Vector3.zero),// + v.RotatedBy(Mathf.Acos(Quaternion.Dot(Quaternion.identity, quat)) * 2f * 57.29578f),
 | 
					 | 
				
			||||||
					quat: Quaternion.AngleAxis(angle: num, axis: Vector3.up) * headQuatInAnimation, mat: graphic.MatAt(rot: pawnAnimator.headFacing), drawNow: drawNow);;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
				
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							GenDraw.DrawMeshNowOrLater(mesh: graphic.MeshAt(rot: headRotInAnimation), loc: loc + orassanv + (bodyAddon.alignWithHead ? headOffset : Vector3.zero),// + v.RotatedBy(Mathf.Acos(Quaternion.Dot(Quaternion.identity, quat)) * 2f * 57.29578f),
 | 
				
			||||||
 | 
									quat: Quaternion.AngleAxis(angle: num, axis: Vector3.up) * headQuatInAnimation, mat: graphic.MatAt(rot: pawnAnimator.headFacing), drawNow: drawNow);;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
		public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
			List<CodeInstruction> ins = instructions.ToList();
 | 
					 | 
				
			||||||
			for (int i = 0; i < ins.Count; i++)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				Type[] type = new Type[] { typeof(Mesh), typeof(Vector3), typeof(Quaternion), typeof(Material), typeof(bool) };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				if (ins[i].OperandIs(AccessTools.Method(typeof(GenDraw), "DrawMeshNowOrLater", type)))
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
					
 | 
					 | 
				
			||||||
					yield return new CodeInstruction(OpCodes.Ldloc, (object)7); //graphic
 | 
					 | 
				
			||||||
					yield return new CodeInstruction(OpCodes.Ldloc, (object)4); //bodyAddon
 | 
					 | 
				
			||||||
					yield return new CodeInstruction(OpCodes.Ldloc, (object)5); //offsetVector/AddonOffset (v)
 | 
					 | 
				
			||||||
					yield return new CodeInstruction(OpCodes.Ldarg, (object)2); //headOffset
 | 
					 | 
				
			||||||
					yield return new CodeInstruction(OpCodes.Ldarg, (object)3); //pawn
 | 
					 | 
				
			||||||
					yield return new CodeInstruction(OpCodes.Ldarg, (object)0); //renderflags
 | 
					 | 
				
			||||||
					yield return new CodeInstruction(OpCodes.Ldarg, (object)1); //vector
 | 
					 | 
				
			||||||
					yield return new CodeInstruction(OpCodes.Ldarg, (object)5); //rotation
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					yield return new CodeInstruction(OpCodes.Call, AccessTools.DeclaredMethod(typeof(HarmonyPatch_AlienRace), "RenderHeadAddonInAnimation"));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
				
 | 
					 | 
				
			||||||
				else
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
					yield return ins[i];
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		public static bool Prefix(PawnRenderFlags renderFlags, ref Vector3 vector, ref Vector3 headOffset, Pawn pawn, ref Quaternion quat, ref Rot4 rotation)
 | 
					 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			if(pawn == null)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
				return true;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
				
 | 
					 | 
				
			||||||
			CompBodyAnimator anim = pawn.TryGetComp<CompBodyAnimator>();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if(anim == null)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
				return true;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (anim != null && !renderFlags.FlagSet(PawnRenderFlags.Portrait) && anim.isAnimating)
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
				//quat = Quaternion.AngleAxis(anim.bodyAngle, Vector3.up);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			return true;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	*/
 | 
						public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							List<CodeInstruction> ins = instructions.ToList();
 | 
				
			||||||
 | 
							for (int i = 0; i < ins.Count; i++)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								Type[] type = new Type[] { typeof(Mesh), typeof(Vector3), typeof(Quaternion), typeof(Material), typeof(bool) };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (ins[i].OperandIs(AccessTools.Method(typeof(GenDraw), "DrawMeshNowOrLater", type)))
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									yield return new CodeInstruction(OpCodes.Ldloc, (object)7); //graphic
 | 
				
			||||||
 | 
									yield return new CodeInstruction(OpCodes.Ldloc, (object)4); //bodyAddon
 | 
				
			||||||
 | 
									yield return new CodeInstruction(OpCodes.Ldloc, (object)5); //offsetVector/AddonOffset (v)
 | 
				
			||||||
 | 
									yield return new CodeInstruction(OpCodes.Ldarg, (object)2); //headOffset
 | 
				
			||||||
 | 
									yield return new CodeInstruction(OpCodes.Ldarg, (object)3); //pawn
 | 
				
			||||||
 | 
									yield return new CodeInstruction(OpCodes.Ldarg, (object)0); //renderflags
 | 
				
			||||||
 | 
									yield return new CodeInstruction(OpCodes.Ldarg, (object)1); //vector
 | 
				
			||||||
 | 
									yield return new CodeInstruction(OpCodes.Ldarg, (object)5); //rotation
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									yield return new CodeInstruction(OpCodes.Call, AccessTools.DeclaredMethod(typeof(HarmonyPatch_AlienRace), "RenderHeadAddonInAnimation"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									yield return ins[i];
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public static bool Prefix(PawnRenderFlags renderFlags, ref Vector3 vector, ref Vector3 headOffset, Pawn pawn, ref Quaternion quat, ref Rot4 rotation)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							if(pawn == null)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								return true;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							CompBodyAnimator anim = pawn.TryGetComp<CompBodyAnimator>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if(anim == null)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								return true;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (anim != null && !renderFlags.FlagSet(PawnRenderFlags.Portrait) && anim.isAnimating)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								//quat = Quaternion.AngleAxis(anim.bodyAngle, Vector3.up);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
| 
						 | 
					@ -36,10 +36,6 @@
 | 
				
			||||||
      <HintPath>..\..\..\..\workshop\content\294100\839005762\1.4\Assemblies\0Harmony.dll</HintPath>
 | 
					      <HintPath>..\..\..\..\workshop\content\294100\839005762\1.4\Assemblies\0Harmony.dll</HintPath>
 | 
				
			||||||
      <Private>False</Private>
 | 
					      <Private>False</Private>
 | 
				
			||||||
    </Reference>
 | 
					    </Reference>
 | 
				
			||||||
    <Reference Include="AlienRace">
 | 
					 | 
				
			||||||
      <HintPath>..\..\..\..\workshop\content\294100\839005762\1.4\Assemblies\AlienRace.dll</HintPath>
 | 
					 | 
				
			||||||
      <Private>False</Private>
 | 
					 | 
				
			||||||
    </Reference>
 | 
					 | 
				
			||||||
    <Reference Include="Assembly-CSharp">
 | 
					    <Reference Include="Assembly-CSharp">
 | 
				
			||||||
      <HintPath>..\..\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
 | 
					      <HintPath>..\..\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
 | 
				
			||||||
      <Private>False</Private>
 | 
					      <Private>False</Private>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue