mirror of
				https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
				synced 2024-08-15 00:43:45 +00:00 
			
		
		
		
	tried tweaking finalizedmaterial facing, still has issues
This commit is contained in:
		
							parent
							
								
									f6c75990f6
								
							
						
					
					
						commit
						7cbbe00c15
					
				
					 5 changed files with 67 additions and 18 deletions
				
			
		
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,58 @@
 | 
			
		|||
using HarmonyLib;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using Verse;
 | 
			
		||||
 | 
			
		||||
namespace Rimworld_Animations
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    [HarmonyPatch(typeof(PawnRenderNodeWorker), "GetFinalizedMaterial")]
 | 
			
		||||
    public class HarmonyPatch_GetFinalizedMaterial
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        public static void Prefix(PawnRenderNode node, ref PawnDrawParms parms)
 | 
			
		||||
        {
 | 
			
		||||
            //fixes issues with multigraphics rendernodes
 | 
			
		||||
            PawnDrawParms_FacingHelper.ChangeFacingParmsToAncestorFacing(node, ref parms);
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    [HarmonyPatch(typeof(PawnRenderNodeWorker), "GetMaterialPropertyBlock")]
 | 
			
		||||
    public class HarmonyPatch_GetMaterialPropertyBlock
 | 
			
		||||
    {
 | 
			
		||||
        public static void Prefix(PawnRenderNode node, ref PawnDrawParms parms)
 | 
			
		||||
        {
 | 
			
		||||
            //needed to return proper materialpropertyblock for different facing node
 | 
			
		||||
            PawnDrawParms_FacingHelper.ChangeFacingParmsToAncestorFacing(node, ref parms);
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public static class PawnDrawParms_FacingHelper
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        //helper class to change the facing of a node to a parent node if that parent node is animating
 | 
			
		||||
        public static void ChangeFacingParmsToAncestorFacing(PawnRenderNode node, ref PawnDrawParms parms)
 | 
			
		||||
        {
 | 
			
		||||
            PawnRenderNode nodeAscendingParentTree = node;
 | 
			
		||||
            while (nodeAscendingParentTree != null)
 | 
			
		||||
            {
 | 
			
		||||
                if (nodeAscendingParentTree.AnimationWorker is AnimationWorker_KeyframesExtended extendedAnimWorker)
 | 
			
		||||
                {
 | 
			
		||||
                    parms.facing = extendedAnimWorker.facingAtTick(node.tree.AnimationTick);
 | 
			
		||||
                    break;
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                nodeAscendingParentTree = nodeAscendingParentTree.parent;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -20,23 +20,8 @@ namespace Rimworld_Animations
 | 
			
		|||
             * Facing offsets fix
 | 
			
		||||
             */
 | 
			
		||||
            //find lowest parent that is animating, or nothing if not animating
 | 
			
		||||
            PawnDrawParms_FacingHelper.ChangeFacingParmsToAncestorFacing(node, ref parms);
 | 
			
		||||
 | 
			
		||||
            //don't do anything if portrait
 | 
			
		||||
            if (parms.Portrait) return true;
 | 
			
		||||
 | 
			
		||||
            PawnRenderNode animatingNode = node;
 | 
			
		||||
            while (animatingNode != null
 | 
			
		||||
                && !(animatingNode.AnimationWorker is AnimationWorker_KeyframesExtended))
 | 
			
		||||
            {
 | 
			
		||||
                animatingNode = animatingNode.parent;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            //if animating parent node found,
 | 
			
		||||
            if (animatingNode?.AnimationWorker is AnimationWorker_KeyframesExtended animatingNodeAnimationWorker)
 | 
			
		||||
            {
 | 
			
		||||
                //change parm to facing to animate correctly
 | 
			
		||||
                parms.facing = animatingNodeAnimationWorker.facingAtTick(__instance.AnimationTick);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            /*
 | 
			
		||||
             * Set Render Node to absolute position
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,10 @@
 | 
			
		|||
<?xml version="1.0" encoding="utf-8" ?>
 | 
			
		||||
<Patch>
 | 
			
		||||
	<!-- hide node when animating -->
 | 
			
		||||
	<!-- 
 | 
			
		||||
	
 | 
			
		||||
	hide node when animating
 | 
			
		||||
	no longer works with new version
 | 
			
		||||
	
 | 
			
		||||
	<Operation Class="PatchOperationSequence">
 | 
			
		||||
		<success>Always</success>
 | 
			
		||||
		<operations>
 | 
			
		||||
| 
						 | 
				
			
			@ -24,4 +28,5 @@
 | 
			
		|||
		</operations>
 | 
			
		||||
	</Operation>
 | 
			
		||||
	
 | 
			
		||||
	-->
 | 
			
		||||
</Patch>
 | 
			
		||||
| 
						 | 
				
			
			@ -118,6 +118,7 @@
 | 
			
		|||
    <Compile Include="1.5\Source\MainTabWindows\WorldComponent_UpdateMainTab.cs" />
 | 
			
		||||
    <Compile Include="1.5\Source\Patches\Harmony_PatchAll.cs" />
 | 
			
		||||
    <Compile Include="1.5\Source\Patches\RimworldPatches\HarmonyPatch_Dialog_DebugRenderTree.cs" />
 | 
			
		||||
    <Compile Include="1.5\Source\Patches\RimworldPatches\HarmonyPatch_GetFinalizedMaterial.cs" />
 | 
			
		||||
    <Compile Include="1.5\Source\Patches\RimworldPatches\HarmonyPatch_PawnRenderer.cs" />
 | 
			
		||||
    <Compile Include="1.5\Source\Patches\RimworldPatches\HarmonyPatch_PawnRenderNode.cs" />
 | 
			
		||||
    <Compile Include="1.5\Source\Patches\RimworldPatches\HarmonyPatch_PawnRenderNodeWorker.cs" />
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue