rimworld-animation-studio/Assets/Scripts/GUI/ActorKeyframeCard.cs
2022-09-21 16:15:25 -05:00

47 lines
No EOL
2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
namespace RimWorldAnimationStudio
{
public class ActorKeyframeCard : Singleton<ActorKeyframeCard>
{
public InputField positionXField;
public InputField positionZField;
public InputField rotationField;
public InputField headBobField;
public InputField headRotationField;
public InputField appendageRotationField;
public void Update()
{
if (Workspace.animationDef == null)
{ return; }
positionXField.interactable = AnimationController.Instance.isAnimating == false;
positionZField.interactable = AnimationController.Instance.isAnimating == false;
rotationField.interactable = AnimationController.Instance.isAnimating == false;
headBobField.interactable = AnimationController.Instance.isAnimating == false;
headRotationField.interactable = AnimationController.Instance.isAnimating == false;
appendageRotationField.interactable = AnimationController.Instance.isAnimating == false;
}
public void OnValueChanged()
{
PawnKeyframe keyframe = Workspace.Instance.GetCurrentPawnKeyframe(true);
keyframe.bodyOffsetX = float.Parse(positionXField.text);
keyframe.bodyOffsetZ = float.Parse(positionZField.text);
keyframe.bodyAngle = float.Parse(rotationField.text);
keyframe.headBob = float.Parse(headBobField.text);
keyframe.headAngle = float.Parse(headRotationField.text);
keyframe.genitalAngle = float.Parse(appendageRotationField.text);
Workspace.animationDef.actors[Workspace.actorID].controlGenitalAngle = keyframe.genitalAngle != 0;
Workspace.Instance.GetPawnAnimationClip(Workspace.actorID).BuildSimpleCurves();
Workspace.Instance.RecordEvent("Actor position / orientation");
}
}
}