mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2024-08-15 00:43:45 +00:00
115 lines
3.3 KiB
C#
115 lines
3.3 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)
|
|
{
|
|
}
|
|
|
|
public override Vector3 OffsetAtTick(int tick, PawnDrawParms parms)
|
|
{
|
|
//Todo: Use this for bodyoffsets
|
|
return base.OffsetAtTick(tick, parms);
|
|
}
|
|
|
|
|
|
|
|
//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;
|
|
|
|
|
|
}
|
|
}
|
|
}
|