Added scale to body type offsets

This commit is contained in:
c0ffee 2024-05-14 10:47:50 -07:00
parent 0b4cca30a2
commit 77874ad5b0
8 changed files with 57 additions and 0 deletions

View file

@ -24,6 +24,12 @@ namespace Rimworld_Animations
List<BodyTypeOffset_AgeRange> pawnOffsets = (pawn.gender == Gender.Male ? offsetsMale : offsetsFemale);
return pawnOffsets.Find(x => x.bodyType == pawn.story.bodyType && x.ageRange.Includes(pawn.ageTracker.AgeBiologicalYears))?.rotation ?? pawnOffsets.Last().rotation;
}
public override Vector3? getScale(Pawn pawn)
{
List<BodyTypeOffset_AgeRange> pawnOffsets = (pawn.gender == Gender.Male ? offsetsMale : offsetsFemale);
return pawnOffsets.Find(x => x.bodyType == pawn.story.bodyType && x.ageRange.Includes(pawn.ageTracker.AgeBiologicalYears))?.scale ?? pawnOffsets.Last().scale;
}
}
public class BodyTypeOffset_AgeRange : BodyTypeOffset

View file

@ -23,6 +23,11 @@ namespace Rimworld_Animations
{
return offsets.Find(x => x.bodyType == pawn.story.bodyType)?.rotation;
}
public override Vector3? getScale(Pawn pawn)
{
return offsets.Find(x => x.bodyType == pawn.story.bodyType)?.scale;
}
}
}

View file

@ -40,5 +40,19 @@ namespace Rimworld_Animations
}
}
public override Vector3? getScale(Pawn pawn)
{
if (pawn.gender == Gender.Female)
{
return offsetsFemale.Find(x => x.bodyType == pawn.story.bodyType)?.scale;
}
else
{
return offsetsMale.Find(x => x.bodyType == pawn.story.bodyType)?.scale;
}
}
}
}

View file

@ -13,6 +13,7 @@ namespace Rimworld_Animations
public Vector3 offset;
public int? rotation;
public Vector3? scale = Vector3.one;
public override Vector3? getOffset(Pawn pawn)
{
@ -23,5 +24,10 @@ namespace Rimworld_Animations
{
return rotation;
}
public override Vector3? getScale(Pawn pawn)
{
return scale;
}
}
}

View file

@ -17,6 +17,8 @@ namespace Rimworld_Animations
public abstract int? getRotation(Pawn pawn);
public abstract Vector3? getScale(Pawn pawn);
public bool appliesToPawn(Pawn pawn)
{
return races.Contains(pawn.def);

View file

@ -14,5 +14,6 @@ namespace Rimworld_Animations
public BodyTypeDef bodyType;
public int rotation = 0;
public Vector3 offset;
public Vector3 scale = Vector3.one;
}
}

View file

@ -87,6 +87,29 @@ namespace Rimworld_Animations
return regularOffsets;
}
public override Vector3 ScaleFor(PawnRenderNode node, PawnDrawParms parms)
{
Vector3 regularScale = base.ScaleFor(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 scale of prop for animationOffset position
regularScale = regularScale.MultipliedBy(offset.getScale(node.tree.pawn) ?? Vector3.one);
return regularScale;
}
}
}
return regularScale;
}
public override Quaternion RotationFor(PawnRenderNode node, PawnDrawParms parms)
{
Quaternion rotation = base.RotationFor(node, parms);