109 lines
3.1 KiB
C#
109 lines
3.1 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
|
|
{
|
|
class AnimationWorker_KeyframesExtended : AnimationWorker_Keyframes
|
|
{
|
|
|
|
public AnimationWorker_KeyframesExtended(AnimationDef def, Pawn pawn, AnimationPart part, PawnRenderNode node) : base(def, pawn, part, node)
|
|
{
|
|
}
|
|
|
|
|
|
|
|
//use extendedkeyframes to determine addon facing
|
|
public Rot4 facingAtTick(int tick)
|
|
{
|
|
//if ticks are < first keyframe tick, just be stuck to first keyframe rot
|
|
if (tick <= this.part.keyframes[0].tick) {
|
|
|
|
return (this.part.keyframes[0] as ExtendedKeyframe).rotation;
|
|
|
|
}
|
|
|
|
//if ticks are > last keyframe tick, just be stuck to last keyframe rot
|
|
if (tick >= this.part.keyframes[this.part.keyframes.Count - 1].tick)
|
|
{
|
|
|
|
return (this.part.keyframes[this.part.keyframes.Count - 1] as ExtendedKeyframe).rotation;
|
|
|
|
}
|
|
Verse.Keyframe keyframe = this.part.keyframes[0];
|
|
Verse.Keyframe keyframe2 = this.part.keyframes[this.part.keyframes.Count - 1];
|
|
int i = 0;
|
|
while (i < this.part.keyframes.Count)
|
|
{
|
|
if (tick <= this.part.keyframes[i].tick)
|
|
{
|
|
keyframe2 = this.part.keyframes[i];
|
|
if (i > 0)
|
|
{
|
|
keyframe = this.part.keyframes[i - 1];
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
i++;
|
|
}
|
|
}
|
|
|
|
return (keyframe as ExtendedKeyframe).rotation;
|
|
|
|
}
|
|
|
|
|
|
public bool visibleAtTick(int tick)
|
|
{
|
|
//if ticks are < first keyframe tick, just be stuck to first keyframe rot
|
|
if (tick <= this.part.keyframes[0].tick)
|
|
{
|
|
|
|
return (this.part.keyframes[0] as ExtendedKeyframe).visible;
|
|
|
|
}
|
|
|
|
//if ticks are > last keyframe tick, just be stuck to last keyframe rot
|
|
if (tick >= this.part.keyframes[this.part.keyframes.Count - 1].tick)
|
|
{
|
|
|
|
return (this.part.keyframes[this.part.keyframes.Count - 1] as ExtendedKeyframe).visible;
|
|
|
|
}
|
|
|
|
Verse.Keyframe keyframe = this.part.keyframes[0];
|
|
Verse.Keyframe keyframe2 = this.part.keyframes[this.part.keyframes.Count - 1];
|
|
|
|
int i = 0;
|
|
while (i < this.part.keyframes.Count)
|
|
{
|
|
if (tick <= this.part.keyframes[i].tick)
|
|
{
|
|
keyframe2 = this.part.keyframes[i];
|
|
if (i > 0)
|
|
{
|
|
keyframe = this.part.keyframes[i - 1];
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
i++;
|
|
}
|
|
}
|
|
|
|
return (keyframe as ExtendedKeyframe).visible;
|
|
|
|
|
|
}
|
|
}
|
|
}
|