rimworld-animation-studio/Assets/Scripts/AnimationComponents/KeyFrames/PawnKeyframe.cs

56 lines
1.7 KiB
C#
Raw Normal View History

2022-09-13 05:36:34 +00:00
using System.Collections.Generic;
using System.Linq;
2022-09-13 05:36:34 +00:00
using System.Xml;
using System.Xml.Serialization;
using UnityEngine;
using UnityEngine.UI;
2022-09-13 05:36:34 +00:00
namespace RimWorldAnimationStudio
{
public class PawnKeyframe : Keyframe
{
public float bodyAngle;
public float headAngle;
public float headBob;
public float bodyOffsetX;
public float bodyOffsetZ;
2022-09-19 05:35:34 +00:00
public float headFacing = 2;
public float bodyFacing = 2;
public float genitalAngle;
2022-09-13 05:36:34 +00:00
public bool? quiver;
2022-09-21 21:15:25 +00:00
[XmlIgnore] public int keyframeID;
2022-10-09 02:15:28 +00:00
[XmlIgnore] public int actorID = -1;
2022-09-21 21:15:25 +00:00
public bool ShouldSerializegenitalAngle() { return genitalAngle != 0; }
public bool ShouldSerializequiver() { return quiver != null; }
2022-09-21 21:15:25 +00:00
public override void ValidateData()
{
soundEffect = Tags.soundDefs.Concat(CustomTags.soundDefs).Contains(soundEffect) ? soundEffect : null;
}
2022-10-09 02:15:28 +00:00
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))))
{
2022-10-09 02:15:28 +00:00
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>();
}
2022-09-13 05:36:34 +00:00
}
}