diff --git a/1.5/Assemblies/Rimworld-Animations.dll b/1.5/Assemblies/Rimworld-Animations.dll index 8685c9d..9135a27 100644 Binary files a/1.5/Assemblies/Rimworld-Animations.dll and b/1.5/Assemblies/Rimworld-Animations.dll differ diff --git a/1.5/Defs/AnimationDefs/Cowgirl/AnimationPropDef_Cowgirl_Xray.xml b/1.5/Defs/AnimationDefs/Cowgirl/AnimationPropDef_Cowgirl_Xray.xml index d7d4895..f804252 100644 --- a/1.5/Defs/AnimationDefs/Cowgirl/AnimationPropDef_Cowgirl_Xray.xml +++ b/1.5/Defs/AnimationDefs/Cowgirl/AnimationPropDef_Cowgirl_Xray.xml @@ -19,6 +19,10 @@ Head 95 TexPathVariants_Cowgirl_Xray + + PropOffsetDef_Cowgirl_Xray + + diff --git a/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderer.cs b/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderer.cs index 6d1e2b8..a013ea7 100644 --- a/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderer.cs +++ b/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderer.cs @@ -11,12 +11,12 @@ namespace Rimworld_Animations [HarmonyPatch(typeof(PawnRenderer), "BodyAngle")] - public class HarmonyPatch_PawnRenderer2 + public class HarmonyPatch_PawnRenderer { public static bool Prefix(ref Pawn ___pawn, ref float __result) { //stop using cache when animating, for when downed (downed disables cache) - if (___pawn.Drawer.renderer.renderTree.rootNode.AnimationWorker is AnimationWorker_KeyframesExtended) + if (___pawn?.Drawer?.renderer?.renderTree?.rootNode?.AnimationWorker is AnimationWorker_KeyframesExtended) { __result = 0; return false; diff --git a/1.5/Source/PawnRenderNode/GraphicVariants/PawnRenderNodeProperties_GraphicVariants.cs b/1.5/Source/PawnRenderNode/GraphicVariants/PawnRenderNodeProperties_GraphicVariants.cs index bd2213f..1b74ba1 100644 --- a/1.5/Source/PawnRenderNode/GraphicVariants/PawnRenderNodeProperties_GraphicVariants.cs +++ b/1.5/Source/PawnRenderNode/GraphicVariants/PawnRenderNodeProperties_GraphicVariants.cs @@ -10,6 +10,7 @@ namespace Rimworld_Animations public class PawnRenderNodeProperties_GraphicVariants : PawnRenderNodeProperties { + public AnimationOffsetDef propOffsetDef = null; public TexPathVariantsDef texPathVariantsDef = null; public bool absoluteTransform = false; diff --git a/1.5/Source/PawnRenderNode/GraphicVariants/PawnRenderNodeWorker_GraphicVariants.cs b/1.5/Source/PawnRenderNode/GraphicVariants/PawnRenderNodeWorker_GraphicVariants.cs index 1192bb0..4a8b195 100644 --- a/1.5/Source/PawnRenderNode/GraphicVariants/PawnRenderNodeWorker_GraphicVariants.cs +++ b/1.5/Source/PawnRenderNode/GraphicVariants/PawnRenderNodeWorker_GraphicVariants.cs @@ -61,9 +61,51 @@ namespace Rimworld_Animations return material; - } + public override Vector3 OffsetFor(PawnRenderNode node, PawnDrawParms parms, out Vector3 pivot) + { + Vector3 regularOffsets = base.OffsetFor(node, parms, out pivot); + if ((node.Props as PawnRenderNodeProperties_GraphicVariants)?.propOffsetDef?.offsets is List offsets) + { + foreach (BaseAnimationOffset offset in offsets) + { + if (offset.appliesToPawn(node.tree.pawn)) + { + //modify offset of prop for animationOffset position + regularOffsets += offset.getOffset(node.tree.pawn) ?? Vector3.zero; + return regularOffsets; + + } + } + } + + //unmodified; no offsets found + return regularOffsets; + } + + public override Quaternion RotationFor(PawnRenderNode node, PawnDrawParms parms) + { + Quaternion rotation = base.RotationFor(node, parms); + + if ((node.Props as PawnRenderNodeProperties_GraphicVariants)?.propOffsetDef?.offsets is List offsets) + { + foreach (BaseAnimationOffset offset in offsets) + { + if (offset.appliesToPawn(node.tree.pawn)) + { + //modify offset of prop for animationOffset rotation + rotation *= Quaternion.AngleAxis(offset.getRotation(node.tree.pawn) ?? 0, Vector3.up); + return rotation; + + } + } + } + + //unmodified; no rotation offsets found + return rotation; + + } } } diff --git a/1.5/Source/PawnRenderNode/GraphicVariants/PawnRenderNode_GraphicVariants.cs b/1.5/Source/PawnRenderNode/GraphicVariants/PawnRenderNode_GraphicVariants.cs index 3dd665c..7b625b4 100644 --- a/1.5/Source/PawnRenderNode/GraphicVariants/PawnRenderNode_GraphicVariants.cs +++ b/1.5/Source/PawnRenderNode/GraphicVariants/PawnRenderNode_GraphicVariants.cs @@ -41,7 +41,7 @@ namespace Rimworld_Animations return GenerateVariants(pawn, props.texPathVariantsDef); - } + } protected override void EnsureMaterialsInitialized() { diff --git a/1.5/Source/RenderSubWorkers/PawnRenderSubWorker_HideWhenAnimating.cs b/1.5/Source/RenderSubWorkers/PawnRenderSubWorker_HideWhenAnimating.cs index 002dffc..2656a1e 100644 --- a/1.5/Source/RenderSubWorkers/PawnRenderSubWorker_HideWhenAnimating.cs +++ b/1.5/Source/RenderSubWorkers/PawnRenderSubWorker_HideWhenAnimating.cs @@ -10,20 +10,6 @@ namespace Rimworld_Animations { public class PawnRenderSubWorker_HideWhenAnimating : PawnRenderSubWorker { - /* hides the entire head node don't use unless you want to do that - public override bool CanDrawNowSub(PawnRenderNode node, PawnDrawParms parms) - { - - if (node.tree.rootNode.AnimationWorker is AnimationWorker_KeyframesExtended - || node.tree.rootNode.children.Any(x => x.AnimationWorker is AnimationWorker_KeyframesExtended)) - { - return false; - - } - - return base.CanDrawNowSub(node, parms); - } - */ public override void EditMaterial(PawnRenderNode node, PawnDrawParms parms, ref Material material) {