mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Manual timeline, cycle and actor tweaking
This commit is contained in:
parent
dfa564759b
commit
1dd7781179
165 changed files with 4040 additions and 166 deletions
67
Assets/Scripts/AnimationComponents/ActorBodyPart.cs
Normal file
67
Assets/Scripts/AnimationComponents/ActorBodyPart.cs
Normal file
|
@ -0,0 +1,67 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace RimWorldAnimationStudio
|
||||
{
|
||||
public class ActorBodyPart : MonoBehaviour, IDragHandler, IPointerClickHandler
|
||||
{
|
||||
public SpriteRenderer bodyPartRenderer;
|
||||
public ActorBody parent;
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
if (eventData.pointerCurrentRaycast.gameObject.GetComponent<ActorBodyPart>() == null)
|
||||
{ return; }
|
||||
|
||||
foreach (ActorBody actorBody in AnimationController.Instance.actorBodies)
|
||||
{
|
||||
actorBody.bodyRenderer.color = new Color(1f, 1f, 1f);
|
||||
actorBody.headRenderer.color = new Color(1f, 1f, 1f);
|
||||
}
|
||||
|
||||
bodyPartRenderer.color = new Color(0f, 1f, 0f);
|
||||
}
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
Vector3 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
PawnKeyframe keyframe = Workspace.animationDef.animationStages[Workspace.stageID].animationClips[parent.actorID].keyframes.FirstOrDefault(x => x.keyframeID == Workspace.keyframeID);
|
||||
|
||||
if (Workspace.actorManipulationMode == ActorManipulationMode.Pan)
|
||||
{
|
||||
float distance = ((Vector2)mousePosition - (Vector2)transform.position).y;
|
||||
Vector3 headOffset = new Vector3(0f, 0.34f, 0f);
|
||||
headOffset = Quaternion.Euler(0, 0, keyframe.bodyAngle) * headOffset;
|
||||
|
||||
distance = Vector2.Dot(parent.transform.up, (Vector2)(mousePosition - parent.transform.position - headOffset));
|
||||
|
||||
Debug.Log(headOffset.ToString());
|
||||
|
||||
Workspace.animationDef.animationStages[Workspace.stageID].animationClips[parent.actorID].keyframes.FirstOrDefault(x => x.keyframeID == Workspace.keyframeID).headBob = distance;
|
||||
}
|
||||
|
||||
else if (Workspace.actorManipulationMode == ActorManipulationMode.Rotate)
|
||||
{
|
||||
float angle = Vector2.SignedAngle(Vector2.down, (Vector2)mousePosition - (Vector2)transform.position);
|
||||
Workspace.animationDef.animationStages[Workspace.stageID].animationClips[parent.actorID].keyframes.FirstOrDefault(x => x.keyframeID == Workspace.keyframeID).headAngle = angle;
|
||||
}
|
||||
|
||||
else if (Workspace.actorManipulationMode == ActorManipulationMode.Face)
|
||||
{
|
||||
float angle = Vector2.SignedAngle(Vector2.up, (Vector2)mousePosition - (Vector2)transform.position);
|
||||
int facing = -Mathf.RoundToInt(angle / 90f);
|
||||
facing = facing < 0 ? facing + 4 : facing;
|
||||
|
||||
Debug.Log(facing.ToString());
|
||||
|
||||
Workspace.animationDef.animationStages[Workspace.stageID].animationClips[parent.actorID].keyframes.FirstOrDefault(x => x.keyframeID == Workspace.keyframeID).headFacing = facing;
|
||||
}
|
||||
|
||||
PawnAnimationClip clip = Workspace.Instance.GetPawnAnimationClip(parent.actorID);
|
||||
clip.BuildSimpleCurves();
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/AnimationComponents/ActorBodyPart.cs.meta
Normal file
11
Assets/Scripts/AnimationComponents/ActorBodyPart.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b23e33f312d52c642b86f5f2138f4030
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -49,8 +49,6 @@ namespace RimWorldAnimationStudio
|
|||
if (keyframe.HasValidKeyframeID() == false)
|
||||
{ keyframe.GenerateKeyframeID(); }
|
||||
|
||||
Debug.Log(keyframe.atTick.Value);
|
||||
|
||||
BodyAngle.Add((float)keyframe.atTick / (float)duration, keyframe.bodyAngle, true);
|
||||
HeadAngle.Add((float)keyframe.atTick / (float)duration, keyframe.headAngle, true);
|
||||
BodyOffsetX.Add((float)keyframe.atTick / (float)duration, keyframe.bodyOffsetX, true);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using UnityEngine;
|
||||
|
@ -25,8 +26,15 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
public void GenerateKeyframeID()
|
||||
{
|
||||
keyframeID = Random.Range(100000, 1000000);
|
||||
Debug.Log("Generated ID: " + keyframeID);
|
||||
int _keyframeID = Random.Range(100000, 1000000);
|
||||
|
||||
if (Workspace.animationDef.animationStages.Any(x => x.animationClips.Any(y => y.keyframes.Any(z => z.keyframeID == _keyframeID))))
|
||||
{
|
||||
GenerateKeyframeID();
|
||||
return;
|
||||
}
|
||||
|
||||
keyframeID = _keyframeID;
|
||||
}
|
||||
|
||||
public bool HasValidKeyframeID()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue