mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2024-08-15 00:43:45 +00:00
commit
This commit is contained in:
parent
74a34b6f8d
commit
55ae1c5d10
29 changed files with 1387 additions and 28 deletions
27
Source/Animations/AnimationStage.cs
Normal file
27
Source/Animations/AnimationStage.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Rimworld_Animations {
|
||||
public class AnimationStage
|
||||
{
|
||||
public string stageName;
|
||||
public int stageIndex;
|
||||
public int playTimeTicks = 0;
|
||||
public bool isLooping;
|
||||
public List<BaseAnimationClip> animationClips;
|
||||
|
||||
|
||||
public void initialize() {
|
||||
foreach (BaseAnimationClip clip in animationClips) {
|
||||
clip.buildSimpleCurves();
|
||||
//select playTimeTicks as longest playtime of all the animations
|
||||
if(clip.duration > playTimeTicks) {
|
||||
playTimeTicks = clip.duration;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
19
Source/Animations/Clips/BaseAnimationClip.cs
Normal file
19
Source/Animations/Clips/BaseAnimationClip.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
|
||||
namespace Rimworld_Animations {
|
||||
public abstract class BaseAnimationClip
|
||||
{
|
||||
public List<ThingDef> types; //types of participants
|
||||
public int duration;
|
||||
public abstract void buildSimpleCurves();
|
||||
public string soundDef = null; //for playing sounds
|
||||
public int actor;
|
||||
|
||||
}
|
||||
}
|
101
Source/Animations/Clips/PawnAnimationClip.cs
Normal file
101
Source/Animations/Clips/PawnAnimationClip.cs
Normal file
|
@ -0,0 +1,101 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
|
||||
namespace Rimworld_Animations {
|
||||
public class PawnAnimationClip : BaseAnimationClip {
|
||||
|
||||
public List<PawnKeyframe> keyframes;
|
||||
public AltitudeLayer layer = AltitudeLayer.Pawn;
|
||||
|
||||
public Dictionary<int, string> SoundEffects = new Dictionary<int, string>();
|
||||
public SimpleCurve BodyAngle = new SimpleCurve();
|
||||
public SimpleCurve HeadAngle = new SimpleCurve();
|
||||
public SimpleCurve HeadBob = new SimpleCurve();
|
||||
public SimpleCurve BodyOffsetX = new SimpleCurve();
|
||||
public SimpleCurve BodyOffsetZ = new SimpleCurve();
|
||||
public SimpleCurve HeadFacing = new SimpleCurve();
|
||||
public SimpleCurve BodyFacing = new SimpleCurve();
|
||||
|
||||
|
||||
public override void buildSimpleCurves() {
|
||||
|
||||
|
||||
int duration = 0;
|
||||
//getting the length of the whole clip
|
||||
foreach(PawnKeyframe frame in keyframes) {
|
||||
duration += frame.tickDuration;
|
||||
}
|
||||
|
||||
//guarantees loops don't get cut off mid-anim
|
||||
this.duration = duration;
|
||||
|
||||
int keyframePosition = 0;
|
||||
foreach (PawnKeyframe frame in keyframes) {
|
||||
|
||||
if (frame.atTick.HasValue) {
|
||||
if (frame.bodyAngle.HasValue)
|
||||
BodyAngle.Add((float)frame.atTick / (float)duration, frame.bodyAngle.Value, true);
|
||||
|
||||
if (frame.headAngle.HasValue)
|
||||
HeadAngle.Add((float)frame.atTick / (float)duration, frame.headAngle.Value, true);
|
||||
|
||||
if (frame.bodyOffsetX.HasValue)
|
||||
BodyOffsetX.Add((float)frame.atTick / (float)duration, frame.bodyOffsetX.Value, true);
|
||||
|
||||
if (frame.bodyOffsetZ.HasValue)
|
||||
BodyOffsetZ.Add((float)frame.atTick / (float)duration, frame.bodyOffsetZ.Value, true);
|
||||
|
||||
if (frame.headFacing.HasValue)
|
||||
HeadFacing.Add((float)frame.atTick / (float)duration, frame.headFacing.Value, true);
|
||||
|
||||
if (frame.bodyFacing.HasValue)
|
||||
BodyFacing.Add((float)frame.atTick / (float)duration, frame.bodyFacing.Value, true);
|
||||
|
||||
if (frame.headBob.HasValue)
|
||||
HeadBob.Add((float)frame.atTick / (float)duration, frame.headBob.Value, true);
|
||||
|
||||
if (frame.soundEffect != null) {
|
||||
SoundEffects.Add((int)frame.atTick, frame.soundEffect);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (frame.bodyAngle.HasValue)
|
||||
BodyAngle.Add((float)keyframePosition / (float)duration, frame.bodyAngle.Value, true);
|
||||
|
||||
if (frame.headAngle.HasValue)
|
||||
HeadAngle.Add((float)keyframePosition / (float)duration, frame.headAngle.Value, true);
|
||||
|
||||
if (frame.bodyOffsetX.HasValue)
|
||||
BodyOffsetX.Add((float)keyframePosition / (float)duration, frame.bodyOffsetX.Value, true);
|
||||
|
||||
if (frame.bodyOffsetZ.HasValue)
|
||||
BodyOffsetZ.Add((float)keyframePosition / (float)duration, frame.bodyOffsetZ.Value, true);
|
||||
|
||||
if (frame.headFacing.HasValue)
|
||||
HeadFacing.Add((float)keyframePosition / (float)duration, frame.headFacing.Value, true);
|
||||
|
||||
if (frame.bodyFacing.HasValue)
|
||||
BodyFacing.Add((float)keyframePosition / (float)duration, frame.bodyFacing.Value, true);
|
||||
|
||||
if (frame.headBob.HasValue)
|
||||
HeadBob.Add((float)keyframePosition / (float)duration, frame.headBob.Value, true);
|
||||
|
||||
if (frame.soundEffect != null) {
|
||||
SoundEffects.Add(keyframePosition, frame.soundEffect);
|
||||
}
|
||||
|
||||
keyframePosition += frame.tickDuration;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
15
Source/Animations/Clips/ThingAnimationClip.cs
Normal file
15
Source/Animations/Clips/ThingAnimationClip.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Rimworld_Animations {
|
||||
public class ThingAnimationClip : BaseAnimationClip
|
||||
{
|
||||
public List<ThingKeyframe> keyframes;
|
||||
|
||||
public override void buildSimpleCurves() {
|
||||
}
|
||||
}
|
||||
}
|
14
Source/Animations/Keyframes/Keyframe.cs
Normal file
14
Source/Animations/Keyframes/Keyframe.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Rimworld_Animations {
|
||||
public abstract class Keyframe
|
||||
{
|
||||
public int tickDuration = 1;
|
||||
|
||||
|
||||
}
|
||||
}
|
27
Source/Animations/Keyframes/PawnKeyframe.cs
Normal file
27
Source/Animations/Keyframes/PawnKeyframe.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
|
||||
namespace Rimworld_Animations {
|
||||
public class PawnKeyframe : Keyframe
|
||||
{
|
||||
public float? bodyAngle;
|
||||
public float? headAngle;
|
||||
|
||||
public float? bodyOffsetZ;
|
||||
public float? bodyOffsetX;
|
||||
|
||||
public float? headBob;
|
||||
//todo: add headOffsets l/r?
|
||||
|
||||
public int? bodyFacing;
|
||||
public int? headFacing;
|
||||
|
||||
public string soundEffect;
|
||||
|
||||
public float? atTick;
|
||||
}
|
||||
}
|
11
Source/Animations/Keyframes/ThingKeyframe.cs
Normal file
11
Source/Animations/Keyframes/ThingKeyframe.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Rimworld_Animations {
|
||||
public class ThingKeyframe : Keyframe
|
||||
{
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue