Added age range body offsets

This commit is contained in:
c0ffee 2024-05-10 15:35:46 -07:00
parent 776c18a715
commit 781e4321dd
4 changed files with 46 additions and 0 deletions

View file

@ -24,6 +24,17 @@
<li><bodyType>Hulk</bodyType><offset>(0, 0, 0.223)</offset></li>
</offsets>
</li>
<!-- An example of age-ranged offsets
<li Class="Rimworld_Animations.AnimationOffset_AgeRange" MayRequire="Mod.ID.Here">
<races>
<li>Moosesian</li>
</races>
<offsetsFemale>
<li><bodyType>Female</bodyType><ageRange>18~24</ageRange><offset>(0, 0, 0.223)</offset></li>
<li><bodyType>Female</bodyType><ageRange>25~100</ageRange><offset>(0, 0, 0.4)</offset></li>
</offsetsFemale>
</li>
-->
</offsets>
</Rimworld_Animations.AnimationOffsetDef>
</Defs>

View file

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using Verse;
namespace Rimworld_Animations
{
public class AnimationOffset_AgeRange : BaseAnimationOffset
{
public List<BodyTypeOffset_AgeRange> offsetsMale;
public List<BodyTypeOffset_AgeRange> offsetsFemale;
public override Vector3? getOffset(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))?.offset ?? pawnOffsets.Last().offset;
}
public override int? getRotation(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))?.rotation ?? pawnOffsets.Last().rotation;
}
}
public class BodyTypeOffset_AgeRange : BodyTypeOffset
{
public FloatRange ageRange;
}
}

View file

@ -77,6 +77,7 @@
<Compile Include="1.5\Source\Actors\Actor.cs" />
<Compile Include="1.5\Source\Actors\AlienRaceOffset.cs" />
<Compile Include="1.5\Source\Animations\AnimationOffsets\AnimationOffsetDef.cs" />
<Compile Include="1.5\Source\Animations\AnimationOffsets\Offsets\AnimationOffset_AgeRange.cs" />
<Compile Include="1.5\Source\Animations\AnimationOffsets\Offsets\AnimationOffset_BodyType.cs" />
<Compile Include="1.5\Source\Animations\AnimationOffsets\Offsets\AnimationOffset_BodyTypeGendered.cs" />
<Compile Include="1.5\Source\Animations\AnimationOffsets\Offsets\AnimationOffset_Single.cs" />