mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
108 lines
No EOL
4.1 KiB
C#
108 lines
No EOL
4.1 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.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.GetPawnAnimationClip(Workspace.ActorID).BuildSimpleCurves();
|
|
Workspace.RecordEvent("Actor position / orientation");
|
|
}
|
|
|
|
public void AdjustActor(Vector2 deltaOffset)
|
|
{
|
|
float deltaAngle = -deltaOffset.x * 33.3333f + deltaOffset.y * 33.3333f;
|
|
int facing = deltaOffset.x < 0 ? 3 : deltaOffset.y < 0 ? 2 : deltaOffset.x > 0 ? 1 : 0;
|
|
|
|
switch (Workspace.actorManipulationMode)
|
|
{
|
|
case ActorManipulationMode.Pan: MoveActor(deltaOffset); break;
|
|
case ActorManipulationMode.Rotate: RotateActor(deltaAngle); break;
|
|
case ActorManipulationMode.Face: FaceActor(facing); break;
|
|
}
|
|
}
|
|
|
|
public void MoveActor(Vector2 deltaOffset)
|
|
{
|
|
PawnKeyframe keyframe = Workspace.GetCurrentPawnKeyframe(true);
|
|
|
|
if (Workspace.selectedBodyPart == null)
|
|
{
|
|
keyframe.BodyOffsetX += deltaOffset.x;
|
|
keyframe.BodyOffsetZ += deltaOffset.y;
|
|
}
|
|
|
|
else if (Workspace.selectedBodyPart.isHead)
|
|
{ keyframe.HeadBob += deltaOffset.y; }
|
|
|
|
Workspace.GetCurrentPawnAnimationClip().BuildSimpleCurves();
|
|
Workspace.RecordEvent("Actor position / orientation");
|
|
}
|
|
|
|
public void RotateActor(float deltaAngle)
|
|
{
|
|
PawnKeyframe keyframe = Workspace.GetCurrentPawnKeyframe(true);
|
|
|
|
if (Workspace.selectedBodyPart == null)
|
|
{ keyframe.BodyAngle += deltaAngle; }
|
|
|
|
else if (Workspace.selectedBodyPart.isHead)
|
|
{ keyframe.HeadAngle += deltaAngle; }
|
|
|
|
else
|
|
{ keyframe.GenitalAngle -= deltaAngle; }
|
|
|
|
Workspace.GetCurrentPawnAnimationClip().BuildSimpleCurves();
|
|
Workspace.RecordEvent("Actor position / orientation");
|
|
}
|
|
|
|
public void FaceActor(int facing)
|
|
{
|
|
PawnKeyframe keyframe = Workspace.GetCurrentPawnKeyframe(true);
|
|
|
|
if (Workspace.selectedBodyPart == null)
|
|
{ keyframe.BodyFacing = facing; }
|
|
|
|
else if (Workspace.selectedBodyPart.isHead)
|
|
{ keyframe.HeadFacing = facing; }
|
|
|
|
Workspace.GetCurrentPawnAnimationClip().BuildSimpleCurves();
|
|
Workspace.RecordEvent("Actor position / orientation");
|
|
}
|
|
}
|
|
} |