rimworld-animations/1.5/Source/Animations/AnimationOffsets/Offsets/AnimationOffset_AgeRange.cs

40 lines
1.5 KiB
C#

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 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
{
public FloatRange ageRange;
}
}