mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2024-08-15 00:43:45 +00:00
fixes to bodyangle throwing null ref errors, and prop animation offsets
This commit is contained in:
parent
d36c2b8314
commit
a491c1dade
7 changed files with 51 additions and 18 deletions
Binary file not shown.
|
@ -19,6 +19,10 @@
|
|||
<overlayLayer>Head</overlayLayer>
|
||||
<baseLayer>95</baseLayer>
|
||||
<texPathVariantsDef>TexPathVariants_Cowgirl_Xray</texPathVariantsDef>
|
||||
|
||||
<propOffsetDef>PropOffsetDef_Cowgirl_Xray</propOffsetDef>
|
||||
|
||||
|
||||
</animPropProperties>
|
||||
</Rimworld_Animations.AnimationPropDef>
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace Rimworld_Animations
|
|||
public class PawnRenderNodeProperties_GraphicVariants : PawnRenderNodeProperties
|
||||
{
|
||||
|
||||
public AnimationOffsetDef propOffsetDef = null;
|
||||
public TexPathVariantsDef texPathVariantsDef = null;
|
||||
public bool absoluteTransform = false;
|
||||
|
||||
|
|
|
@ -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<BaseAnimationOffset> 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<BaseAnimationOffset> 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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace Rimworld_Animations
|
|||
|
||||
return GenerateVariants(pawn, props.texPathVariantsDef);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected override void EnsureMaterialsInitialized()
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue