mirror of
				https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
				synced 2024-08-15 00:43:45 +00:00 
			
		
		
		
	pre-1.3 update WIP
This commit is contained in:
		
							parent
							
								
									7c2151fd76
								
							
						
					
					
						commit
						6d4ed2a9e3
					
				
					 14 changed files with 190 additions and 107 deletions
				
			
		
							
								
								
									
										
											BIN
										
									
								
								1.3/Assemblies/Rimworld-Animations.dll
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								1.3/Assemblies/Rimworld-Animations.dll
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
					@ -7,6 +7,7 @@
 | 
				
			||||||
	<supportedVersions>
 | 
						<supportedVersions>
 | 
				
			||||||
		<li>1.1</li>
 | 
							<li>1.1</li>
 | 
				
			||||||
		<li>1.2</li>
 | 
							<li>1.2</li>
 | 
				
			||||||
 | 
							<li>1.3</li>
 | 
				
			||||||
	</supportedVersions>
 | 
						</supportedVersions>
 | 
				
			||||||
	<packageId>c0ffee.rimworld.animations</packageId>
 | 
						<packageId>c0ffee.rimworld.animations</packageId>
 | 
				
			||||||
	<modDependencies>
 | 
						<modDependencies>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,5 +9,10 @@
 | 
				
			||||||
		<li>1.2</li>
 | 
							<li>1.2</li>
 | 
				
			||||||
		<li IfModActive="velc.HatsDisplaySelection">Patch_HatsDisplaySelection/1.2</li>
 | 
							<li IfModActive="velc.HatsDisplaySelection">Patch_HatsDisplaySelection/1.2</li>
 | 
				
			||||||
	</v1.2>
 | 
						</v1.2>
 | 
				
			||||||
 | 
						<v1.3>
 | 
				
			||||||
 | 
							<li>/</li>
 | 
				
			||||||
 | 
							<li>1.3</li>
 | 
				
			||||||
 | 
							<li IfModActive="velc.HatsDisplaySelection">Patch_HatsDisplaySelection/1.2</li>
 | 
				
			||||||
 | 
						</v1.3>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</loadFolders>
 | 
					</loadFolders>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,8 +39,12 @@
 | 
				
			||||||
      <HintPath>..\..\..\..\workshop\content\294100\839005762\1.2\Assemblies\AlienRace.dll</HintPath>
 | 
					      <HintPath>..\..\..\..\workshop\content\294100\839005762\1.2\Assemblies\AlienRace.dll</HintPath>
 | 
				
			||||||
      <Private>False</Private>
 | 
					      <Private>False</Private>
 | 
				
			||||||
    </Reference>
 | 
					    </Reference>
 | 
				
			||||||
 | 
					    <Reference Include="Assembly-CSharp">
 | 
				
			||||||
 | 
					      <HintPath>..\..\RimWorldWin64_Data\Managed\Assembly-CSharp.dll</HintPath>
 | 
				
			||||||
 | 
					      <Private>False</Private>
 | 
				
			||||||
 | 
					    </Reference>
 | 
				
			||||||
    <Reference Include="RJW">
 | 
					    <Reference Include="RJW">
 | 
				
			||||||
      <HintPath>..\rjw-master\1.2\Assemblies\RJW.dll</HintPath>
 | 
					      <HintPath>..\rjw\1.3\Assemblies\RJW.dll</HintPath>
 | 
				
			||||||
      <Private>False</Private>
 | 
					      <Private>False</Private>
 | 
				
			||||||
    </Reference>
 | 
					    </Reference>
 | 
				
			||||||
    <Reference Include="System" />
 | 
					    <Reference Include="System" />
 | 
				
			||||||
| 
						 | 
					@ -93,6 +97,7 @@
 | 
				
			||||||
    <Compile Include="Source\Patches\HarmonyPatch_PawnRenderer.cs" />
 | 
					    <Compile Include="Source\Patches\HarmonyPatch_PawnRenderer.cs" />
 | 
				
			||||||
    <Compile Include="Source\Patches\HarmonyPatch_PawnRotation.cs" />
 | 
					    <Compile Include="Source\Patches\HarmonyPatch_PawnRotation.cs" />
 | 
				
			||||||
    <Compile Include="Source\Patches\HarmonyPatch_Pawn_DrawTracker.cs" />
 | 
					    <Compile Include="Source\Patches\HarmonyPatch_Pawn_DrawTracker.cs" />
 | 
				
			||||||
 | 
					    <Compile Include="Source\Patches\HarmonyPatch_SetPawnAnimatable.cs" />
 | 
				
			||||||
    <Compile Include="Source\Patches\HarmonyPatch_ShowHairWithHats.cs" />
 | 
					    <Compile Include="Source\Patches\HarmonyPatch_ShowHairWithHats.cs" />
 | 
				
			||||||
    <Compile Include="Source\Patches\Harmony_PatchAll.cs" />
 | 
					    <Compile Include="Source\Patches\Harmony_PatchAll.cs" />
 | 
				
			||||||
    <Compile Include="Source\Patches\rjwPatches\HarmonyPatch_DoLovinAnimationPatch.cs" />
 | 
					    <Compile Include="Source\Patches\rjwPatches\HarmonyPatch_DoLovinAnimationPatch.cs" />
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -51,7 +51,7 @@ namespace Rimworld_Animations {
 | 
				
			||||||
							" ",
 | 
												" ",
 | 
				
			||||||
							localParticipants[i].Name.ToStringSafe<Name>(),
 | 
												localParticipants[i].Name.ToStringSafe<Name>(),
 | 
				
			||||||
							" does not match required gender"
 | 
												" does not match required gender"
 | 
				
			||||||
						}), false);
 | 
											}));
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
					return false;
 | 
										return false;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
| 
						 | 
					@ -276,5 +276,15 @@ namespace Rimworld_Animations {
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static Rot4 PawnHeadRotInAnimation(Pawn pawn, Rot4 regularPos)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if(pawn?.TryGetComp<CompBodyAnimator>() != null && pawn.TryGetComp<CompBodyAnimator>().isAnimating)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return pawn.TryGetComp<CompBodyAnimator>().headFacing;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return regularPos;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,7 +32,6 @@ namespace Rimworld_Animations {
 | 
				
			||||||
                    actorsInCurrentAnimation = null;
 | 
					                    actorsInCurrentAnimation = null;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                PortraitsCache.SetDirty(pawn);
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        private bool Animating = false;
 | 
					        private bool Animating = false;
 | 
				
			||||||
| 
						 | 
					@ -179,6 +178,9 @@ namespace Rimworld_Animations {
 | 
				
			||||||
            base.CompTick();
 | 
					            base.CompTick();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if(isAnimating) {
 | 
					            if(isAnimating) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                GlobalTextureAtlasManager.TryMarkPawnFrameSetDirty(pawn);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (pawn.Dead || pawn?.jobs?.curDriver == null || (pawn?.jobs?.curDriver != null && !(pawn?.jobs?.curDriver is rjw.JobDriver_Sex))) {
 | 
					                if (pawn.Dead || pawn?.jobs?.curDriver == null || (pawn?.jobs?.curDriver != null && !(pawn?.jobs?.curDriver is rjw.JobDriver_Sex))) {
 | 
				
			||||||
                    isAnimating = false;
 | 
					                    isAnimating = false;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
| 
						 | 
					@ -187,7 +189,7 @@ namespace Rimworld_Animations {
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        public void animatePawn(ref Vector3 rootLoc, ref float angle, ref Rot4 bodyFacing, ref Rot4 headFacing) {
 | 
					        public void animatePawnBody(ref Vector3 rootLoc, ref float angle, ref Rot4 bodyFacing) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if(!isAnimating) {
 | 
					            if(!isAnimating) {
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
| 
						 | 
					@ -195,19 +197,23 @@ namespace Rimworld_Animations {
 | 
				
			||||||
            rootLoc = anchor + deltaPos;
 | 
					            rootLoc = anchor + deltaPos;
 | 
				
			||||||
            angle = bodyAngle;
 | 
					            angle = bodyAngle;
 | 
				
			||||||
            bodyFacing = this.bodyFacing;
 | 
					            bodyFacing = this.bodyFacing;
 | 
				
			||||||
            headFacing = this.headFacing;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public Rot4 AnimateHeadFacing()
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return this.headFacing;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void tickGraphics(PawnGraphicSet graphics) {
 | 
					        public void tickGraphics(PawnGraphicSet graphics) {
 | 
				
			||||||
            this.Graphics = graphics;
 | 
					            this.Graphics = graphics;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void tickAnim() {
 | 
					        public void tickAnim() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (!isAnimating) return;
 | 
					            if (!isAnimating) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (anim == null) {
 | 
					            if (anim == null) {
 | 
				
			||||||
| 
						 | 
					@ -231,6 +237,9 @@ namespace Rimworld_Animations {
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public void tickStage()
 | 
					        public void tickStage()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -65,7 +65,8 @@ namespace Rimworld_Animations {
 | 
				
			||||||
			get_loved.handlingFacing = true;
 | 
								get_loved.handlingFacing = true;
 | 
				
			||||||
			get_loved.AddPreTickAction(delegate {
 | 
								get_loved.AddPreTickAction(delegate {
 | 
				
			||||||
				if (pawn.IsHashIntervalTick(ticks_between_hearts))
 | 
									if (pawn.IsHashIntervalTick(ticks_between_hearts))
 | 
				
			||||||
					MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart);
 | 
										FleckMaker.ThrowMetaIcon(pawn.Position, pawn.Map, FleckDefOf.Heart);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			});
 | 
								});
 | 
				
			||||||
			get_loved.AddEndCondition(() =>
 | 
								get_loved.AddEndCondition(() =>
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -65,7 +65,7 @@ namespace Rimworld_Animations {
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if(Gen.IsHashIntervalTick(pawn, ticks_between_hearts)) {
 | 
					                if(Gen.IsHashIntervalTick(pawn, ticks_between_hearts)) {
 | 
				
			||||||
                    MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Heart);
 | 
					                    FleckMaker.ThrowMetaIcon(pawn.Position, pawn.Map, FleckDefOf.Heart);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                SexTick(pawn, Partner);
 | 
					                SexTick(pawn, Partner);
 | 
				
			||||||
                SexUtility.reduce_rest(Partner);
 | 
					                SexUtility.reduce_rest(Partner);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -119,8 +119,6 @@ namespace Rimworld_Animations {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            listingStandard.End();
 | 
					            listingStandard.End();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            base.DoWindowContents(inRect);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public override void PreOpen() {
 | 
					        public override void PreOpen() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -54,7 +54,10 @@ namespace Rimworld_Animations {
 | 
				
			||||||
            for (int i = 0; i < instructions.Count(); i++) {
 | 
					            for (int i = 0; i < instructions.Count(); i++) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
                if (codes[i].OperandIs(drawMeshNowOrLater)) {
 | 
					                if (codes[i].
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(drawMeshNowOrLater)) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    yield return new CodeInstruction(OpCodes.Ldarg_0);
 | 
					                    yield return new CodeInstruction(OpCodes.Ldarg_0);
 | 
				
			||||||
                    yield return new CodeInstruction(OpCodes.Ldfld, AccessTools.DeclaredField(AccessTools.TypeByName("HatDisplaySelection.Patch"), "pawn"));
 | 
					                    yield return new CodeInstruction(OpCodes.Ldfld, AccessTools.DeclaredField(AccessTools.TypeByName("HatDisplaySelection.Patch"), "pawn"));
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,109 +14,71 @@ namespace Rimworld_Animations {
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	[HarmonyPatch(typeof(PawnRenderer), "RenderPawnInternal", new Type[]
 | 
						[HarmonyPatch(typeof(PawnRenderer), "RenderPawnInternal", new Type[]
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			typeof(Vector3),
 | 
					 | 
				
			||||||
			typeof(float),
 | 
					 | 
				
			||||||
			typeof(bool),
 | 
					 | 
				
			||||||
			typeof(Rot4),
 | 
					 | 
				
			||||||
			typeof(Rot4),
 | 
					 | 
				
			||||||
			typeof(RotDrawMode),
 | 
					 | 
				
			||||||
			typeof(bool),
 | 
					 | 
				
			||||||
			typeof(bool),
 | 
					 | 
				
			||||||
			typeof(bool)
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	)]
 | 
					 | 
				
			||||||
	public static class HarmonyPatch_PawnRenderer {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		[HarmonyBefore(new string[] { "showhair.kv.rw", "erdelf.HumanoidAlienRaces", "Nals.FacialAnimation" })]
 | 
					 | 
				
			||||||
		public static void Prefix(PawnRenderer __instance, ref Vector3 rootLoc, ref float angle, bool renderBody, ref Rot4 bodyFacing, ref Rot4 headFacing, RotDrawMode bodyDrawType, bool portrait, bool headStump, bool invisible) {
 | 
					 | 
				
			||||||
			PawnGraphicSet graphics = __instance.graphics;
 | 
					 | 
				
			||||||
			Pawn pawn = graphics.pawn;
 | 
					 | 
				
			||||||
			CompBodyAnimator bodyAnim = pawn.TryGetComp<CompBodyAnimator>();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (!graphics.AllResolved) {
 | 
					 | 
				
			||||||
				graphics.ResolveAllGraphics();
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (bodyAnim != null && bodyAnim.isAnimating && !portrait && pawn.Map == Find.CurrentMap) {
 | 
					 | 
				
			||||||
				bodyAnim.tickGraphics(graphics);
 | 
					 | 
				
			||||||
				bodyAnim.animatePawn(ref rootLoc, ref angle, ref bodyFacing, ref headFacing);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	[StaticConstructorOnStartup]
 | 
					 | 
				
			||||||
	public static class HarmonyPatch_Animate
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		static HarmonyPatch_Animate() {
 | 
					 | 
				
			||||||
			// hats display selection patch -- broken
 | 
					 | 
				
			||||||
			/*
 | 
					 | 
				
			||||||
			if (LoadedModManager.RunningModsListForReading.Any(x => x.Name == "Hats Display Selection")) {
 | 
					 | 
				
			||||||
				HarmonyPatch_HatsDisplaySelection.PatchHatsDisplaySelectionArgs();
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			else {
 | 
					 | 
				
			||||||
				PatchRimworldFunctionsNormally();
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			PatchRimworldFunctionsNormally();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		static void PatchRimworldFunctionsNormally() {
 | 
					 | 
				
			||||||
			(new Harmony("rjw")).Patch(AccessTools.Method(typeof(PawnRenderer), "RenderPawnInternal", parameters: new Type[]
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
					typeof(Vector3),
 | 
										typeof(Vector3),
 | 
				
			||||||
					typeof(float),
 | 
										typeof(float),
 | 
				
			||||||
					typeof(bool),
 | 
										typeof(bool),
 | 
				
			||||||
					typeof(Rot4),
 | 
										typeof(Rot4),
 | 
				
			||||||
					typeof(Rot4),
 | 
					 | 
				
			||||||
					typeof(RotDrawMode),
 | 
										typeof(RotDrawMode),
 | 
				
			||||||
					typeof(bool),
 | 
										typeof(PawnRenderFlags)
 | 
				
			||||||
					typeof(bool),
 | 
					 | 
				
			||||||
					typeof(bool)
 | 
					 | 
				
			||||||
				}),
 | 
					 | 
				
			||||||
				transpiler: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_Animate), "Transpiler")));
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						)]
 | 
				
			||||||
 | 
						public static class HarmonyPatch_PawnRenderer
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		[HarmonyAfter(new string[] { "showhair.kv.rw", "erdelf.HumanoidAlienRaces", "Nals.FacialAnimation" })]
 | 
							[HarmonyBefore(new string[] { "showhair.kv.rw", "erdelf.HumanoidAlienRaces", "Nals.FacialAnimation" })]
 | 
				
			||||||
		[HarmonyReversePatch(HarmonyReversePatchType.Snapshot)]
 | 
							public static void Prefix(PawnRenderer __instance, ref Vector3 rootLoc, ref float angle, bool renderBody, ref Rot4 bodyFacing, RotDrawMode bodyDrawType, PawnRenderFlags flags)
 | 
				
			||||||
		public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) {
 | 
							{
 | 
				
			||||||
 | 
								PawnGraphicSet graphics = __instance.graphics;
 | 
				
			||||||
			MethodInfo drawMeshNowOrLater = AccessTools.Method(typeof(GenDraw), "DrawMeshNowOrLater");
 | 
								Pawn pawn = graphics.pawn;
 | 
				
			||||||
			FieldInfo headGraphic = AccessTools.Field(typeof(PawnGraphicSet), "headGraphic");
 | 
								CompBodyAnimator bodyAnim = pawn.TryGetComp<CompBodyAnimator>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			List<CodeInstruction> codes = instructions.ToList();
 | 
								if (bodyAnim != null && bodyAnim.isAnimating && pawn.Map == Find.CurrentMap)
 | 
				
			||||||
			bool forHead = true;
 | 
								{
 | 
				
			||||||
			for(int i = 0; i < codes.Count(); i++) {
 | 
									bodyAnim.animatePawnBody(ref rootLoc, ref angle, ref bodyFacing);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				//Instead of calling drawmeshnoworlater, add pawn to the stack and call my special static method
 | 
					 | 
				
			||||||
				if (codes[i].OperandIs(drawMeshNowOrLater) && forHead) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					yield return new CodeInstruction(OpCodes.Ldarg_0);
 | 
					 | 
				
			||||||
					yield return new CodeInstruction(OpCodes.Ldfld, AccessTools.DeclaredField(typeof(PawnRenderer), "pawn"));
 | 
					 | 
				
			||||||
					yield return new CodeInstruction(OpCodes.Call, AccessTools.DeclaredMethod(typeof(AnimationUtility), nameof(AnimationUtility.RenderPawnHeadMeshInAnimation), new Type[] { typeof(Mesh), typeof(Vector3), typeof(Quaternion), typeof(Material), typeof(bool), typeof(Pawn) }));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				//checking for if(graphics.headGraphic != null)
 | 
					 | 
				
			||||||
				else if (codes[i].opcode == OpCodes.Ldfld && codes[i].OperandIs(headGraphic)) {
 | 
					 | 
				
			||||||
					forHead = true;
 | 
					 | 
				
			||||||
					yield return codes[i];
 | 
					 | 
				
			||||||
				} 
 | 
					 | 
				
			||||||
				//checking for if(renderbody)
 | 
					 | 
				
			||||||
				else if(codes[i].opcode == OpCodes.Ldarg_3) {
 | 
					 | 
				
			||||||
					forHead = false;
 | 
					 | 
				
			||||||
					yield return codes[i];
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				else {
 | 
					 | 
				
			||||||
					yield return codes[i];
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
    }
 | 
					
 | 
				
			||||||
 | 
							public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								bool forHead = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								foreach (CodeInstruction i in instructions)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									
 | 
				
			||||||
 | 
									if (i.opcode == OpCodes.Ldfld && i.OperandIs(AccessTools.Field(typeof(PawnGraphicSet), "headGraphic")))
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										forHead = true;
 | 
				
			||||||
 | 
										yield return i;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									else if (forHead && i.operand == (object)7)
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										yield return new CodeInstruction(OpCodes.Ldarg_0);
 | 
				
			||||||
 | 
										yield return new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(PawnRenderer), "pawn"));
 | 
				
			||||||
 | 
										yield return new CodeInstruction(OpCodes.Ldloc_S, operand: 7);
 | 
				
			||||||
 | 
										yield return new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(AnimationUtility), "PawnHeadRotInAnimation"));
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									else
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
										yield return i;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									
 | 
				
			||||||
 | 
									
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,4 +25,25 @@ namespace Rimworld_Animations {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    [HarmonyPatch(typeof(PawnRenderer), "BodyAngle")]
 | 
				
			||||||
 | 
					    public static class HarmonyPatch_PawnAngle
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        public static bool Prefix(Pawn ___pawn, ref float __result)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if(___pawn.TryGetComp<CompBodyAnimator>().isAnimating)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                __result = ___pawn.TryGetComp<CompBodyAnimator>().bodyAngle;
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										40
									
								
								Source/Patches/HarmonyPatch_SetPawnAnimatable.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								Source/Patches/HarmonyPatch_SetPawnAnimatable.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,40 @@
 | 
				
			||||||
 | 
					using HarmonyLib;
 | 
				
			||||||
 | 
					using RimWorld;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Reflection.Emit;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					using UnityEngine;
 | 
				
			||||||
 | 
					using Verse;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Rimworld_Animations
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						[HarmonyPatch(typeof(PawnRenderer), "RenderPawnAt")]
 | 
				
			||||||
 | 
						public static class PawnRenderer_RenderPawnAt_Patch
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							static bool ClearCache(Pawn pawn)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								return pawn.IsInvisible() || pawn.TryGetComp<CompBodyAnimator>().isAnimating;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								var list = instructions.ToList();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								foreach (CodeInstruction i in instructions)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									if (i.OperandIs(AccessTools.Method(typeof(PawnUtility), "IsInvisible")))
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										yield return new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(PawnRenderer_RenderPawnAt_Patch), "ClearCache"));
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									else
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										yield return i;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										28
									
								
								Source/Patches/HarmonyPatch_SetPawnLaying.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								Source/Patches/HarmonyPatch_SetPawnLaying.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,28 @@
 | 
				
			||||||
 | 
					using HarmonyLib;
 | 
				
			||||||
 | 
					using Verse;
 | 
				
			||||||
 | 
					using RimWorld;
 | 
				
			||||||
 | 
					using System;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using System.Linq;
 | 
				
			||||||
 | 
					using System.Text;
 | 
				
			||||||
 | 
					using System.Threading.Tasks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Rimworld_Animations
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    [HarmonyPatch(typeof(PawnUtility), "GetPosture")]
 | 
				
			||||||
 | 
					    public static class HarmonyPatch_SetPawnLaying
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public static bool Prefix(Pawn p, ref PawnPosture __result)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if(p.TryGetComp<CompBodyAnimator>().isAnimating)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                __result = PawnPosture.LayingOnGroundNormal;
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue