mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2026-06-18 19:35:58 +00:00
42 lines
1.7 KiB
C#
42 lines
1.7 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> offsets;
|
|
|
|
public override Vector3? getOffset(Pawn pawn)
|
|
{
|
|
return offsets.Find(x => x.bodyType == pawn.story.bodyType && x.ageRange.Includes(pawn.ageTracker.AgeBiologicalYears))?.offset
|
|
|
|
//if outside of range, and less than the smallest element, use smallest element offset; else use largest element offset
|
|
?? (pawn.ageTracker.AgeBiologicalYears < offsets.First().ageRange.min ? offsets.First().offset : offsets.Last().offset);
|
|
}
|
|
|
|
public override int? getRotation(Pawn pawn)
|
|
{
|
|
return offsets.Find(x => x.bodyType == pawn.story.bodyType && x.ageRange.Includes(pawn.ageTracker.AgeBiologicalYears))?.rotation
|
|
?? (pawn.ageTracker.AgeBiologicalYears < offsets.First().ageRange.min ? offsets.First().rotation : offsets.Last().rotation);
|
|
}
|
|
|
|
public override Vector3? getScale(Pawn pawn)
|
|
{
|
|
return offsets.Find(x => x.bodyType == pawn.story.bodyType && x.ageRange.Includes(pawn.ageTracker.AgeBiologicalYears))?.scale
|
|
?? (pawn.ageTracker.AgeBiologicalYears < offsets.First().ageRange.min ? offsets.First().scale : offsets.Last().scale);
|
|
}
|
|
|
|
public override bool appliesToPawn(Pawn pawn)
|
|
{
|
|
if (!base.appliesToPawn(pawn)) return false;
|
|
return offsets.Any(x => x.bodyType == pawn.story.bodyType);
|
|
|
|
}
|
|
}
|
|
}
|