mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
55 lines
1.7 KiB
C#
55 lines
1.7 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Xml;
|
|
using System.Xml.Serialization;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace RimWorldAnimationStudio
|
|
{
|
|
public class PawnKeyframe : Keyframe
|
|
{
|
|
public float bodyAngle;
|
|
public float headAngle;
|
|
public float headBob;
|
|
public float bodyOffsetX;
|
|
public float bodyOffsetZ;
|
|
public float headFacing = 2;
|
|
public float bodyFacing = 2;
|
|
|
|
public float genitalAngle;
|
|
public bool? quiver;
|
|
[XmlIgnore] public int keyframeID;
|
|
[XmlIgnore] public int actorID = -1;
|
|
|
|
public bool ShouldSerializegenitalAngle() { return genitalAngle != 0; }
|
|
public bool ShouldSerializequiver() { return quiver != null; }
|
|
|
|
public override void ValidateData()
|
|
{
|
|
soundEffect = Tags.soundDefs.Concat(CustomTags.soundDefs).Contains(soundEffect) ? soundEffect : null;
|
|
}
|
|
|
|
public void GenerateKeyframeID(int actorID)
|
|
{
|
|
this.actorID = actorID;
|
|
int _keyframeID = Random.Range(100000, 1000000);
|
|
|
|
if (Workspace.animationDef.animationStages.Any(x => x.animationClips.Any(y => y.keyframes.Any(z => z.keyframeID == _keyframeID))))
|
|
{
|
|
GenerateKeyframeID(actorID);
|
|
return;
|
|
}
|
|
|
|
keyframeID = _keyframeID;
|
|
}
|
|
|
|
public bool HasValidKeyframeID()
|
|
{ return keyframeID >= 100000 && keyframeID < 1000000; }
|
|
|
|
public KeyframeSlider GetKeyframeSlider()
|
|
{
|
|
return Selectable.allSelectablesArray.FirstOrDefault(x => x.GetComponent<KeyframeSlider>()?.keyframeID == keyframeID)?.GetComponent< KeyframeSlider>();
|
|
}
|
|
}
|
|
}
|