Improvements to timeline

This commit is contained in:
AbstractConcept 2022-09-18 01:52:54 -05:00
parent d2ca61c61c
commit 591b176924
99 changed files with 460 additions and 359 deletions

View file

@ -72,12 +72,12 @@ namespace RimWorldAnimationStudio
if (actorBody == this)
{ continue; }
actorBody.bodyRenderer.color = new Color(1f, 1f, 1f);
actorBody.headRenderer.color = new Color(1f, 1f, 1f);
actorBody.bodyRenderer.color = Constants.ColorWhite;
actorBody.headRenderer.color = Constants.ColorWhite;
}
bodyRenderer.color = new Color(0f, 1f, 0f);
headRenderer.color = new Color(0f, 1f, 0f);
bodyRenderer.color = Constants.ColorGreen;
headRenderer.color = Constants.ColorGreen;
}
}
}

View file

@ -23,26 +23,29 @@ namespace RimWorldAnimationStudio
{
Activate();
PawnKeyframe keyframe = Workspace.Instance.GetCurrentPawnKeyframe();
if (Workspace.Instance.GetCurrentPawnKeyframe() == null)
{ Debug.LogWarning("Cannot alter actor - no keyframe data available"); return; }
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;
keyframe.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;
keyframe.headAngle = angle;
}
else if (Workspace.actorManipulationMode == ActorManipulationMode.Face)
@ -51,9 +54,7 @@ namespace RimWorldAnimationStudio
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;
keyframe.headFacing = facing;
}
PawnAnimationClip clip = Workspace.Instance.GetPawnAnimationClip(parent.actorID);
@ -66,11 +67,11 @@ namespace RimWorldAnimationStudio
foreach (ActorBody actorBody in AnimationController.Instance.GetComponentsInChildren<ActorBody>())
{
actorBody.bodyRenderer.color = new Color(1f, 1f, 1f);
actorBody.headRenderer.color = new Color(1f, 1f, 1f);
actorBody.bodyRenderer.color = Constants.ColorWhite;
actorBody.headRenderer.color = Constants.ColorWhite;
}
bodyPartRenderer.color = new Color(0f, 1f, 0f);
bodyPartRenderer.color = Constants.ColorGreen;
}
}
}

View file

@ -66,12 +66,10 @@ namespace RimWorldAnimationStudio
if (ghostSliders.childCount <= i)
{ Instantiate(ghostSliderPrefab, ghostSliders); }
GameObject ghostSliderObject = ghostSliders.GetChild(i).gameObject;
Debug.Log(ghostSliderObject);
GameObject ghostSliderObject = ghostSliders.GetChild(i).gameObject;
ghostSliderObject.SetActive(true);
Slider ghostSlider = ghostSliderObject.GetComponent<Slider>();
Debug.Log(ghostSlider);
ghostSlider.value = (int)((i + 1) * clip.duration + keyframe.atTick);
float mult = 1f - Mathf.Pow((float)i / maxGhosts, 2);
@ -96,12 +94,20 @@ namespace RimWorldAnimationStudio
public void OnPointerClick(PointerEventData eventData)
{
Activate();
Workspace.actorID = actorID;
Workspace.keyframeID = keyframeID;
if (eventData.clickCount >= 2)
{
AnimationController.Instance.stageTick = keyframe.atTick.Value;
}
}
public void OnBeginDrag(PointerEventData eventData)
{
Activate();
AnimationController.Instance.stageTick = keyframe.atTick.Value;
Workspace.actorID = actorID;
Workspace.keyframeID = keyframeID;
if (keyframe.atTick == 1)
{ return; }
@ -113,7 +119,8 @@ namespace RimWorldAnimationStudio
{
base.OnDrag(eventData);
Activate();
AnimationController.Instance.stageTick = keyframe.atTick.Value;
Workspace.actorID = actorID;
}
public void OnEndDrag(PointerEventData eventData)
@ -121,23 +128,21 @@ namespace RimWorldAnimationStudio
interactable = false;
}
public void Activate()
protected override void Update()
{
AnimationController.Instance.stageTick = keyframe.atTick.Value;
base.Update();
Workspace.keyframeID = keyframeID;
if (Workspace.keyframeID == keyframeID && AnimationController.Instance.stageTick == keyframe.atTick.Value)
{ transform.FindDeepChild("Handle").GetComponent<Image>().color = Constants.ColorPurple; }
foreach (AnimationTimeline _timeline in AnimationController.Instance.animationTimelines.GetComponentsInChildren<AnimationTimeline>())
{
foreach (KeyframeSlider keyframeSlider in _timeline.GetComponentsInChildren<KeyframeSlider>())
{
if (keyframeSlider.keyframe.atTick.Value == keyframe.atTick.Value)
{ keyframeSlider.transform.FindDeepChild("Handle").GetComponent<Image>().color = new Color(0f, 1f, 0f); }
else if (Workspace.keyframeID == keyframeID)
{ transform.FindDeepChild("Handle").GetComponent<Image>().color = Constants.ColorCyan; }
else
{ keyframeSlider.transform.FindDeepChild("Handle").GetComponent<Image>().color = new Color(1f, 1f, 1f); }
}
}
else if (AnimationController.Instance.stageTick == keyframe.atTick.Value)
{ transform.FindDeepChild("Handle").GetComponent<Image>().color = Constants.ColorPink; }
else
{ transform.FindDeepChild("Handle").GetComponent<Image>().color = Constants.ColorWhite; }
}
}
}

View file

@ -60,8 +60,8 @@ namespace RimWorldAnimationStudio
Workspace.stageID = transform.GetSiblingIndex();
AnimationController.Instance.ResetAnimationTimeline();
AnimationController.Instance.InitializeAnimationTimeline();
//AnimationController.Instance.ResetAnimationTimeline();
//AnimationController.Instance.InitializeAnimationTimeline();
}
}
}