mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Improved adding and removal of anim events
This commit is contained in:
parent
f0d46df3d6
commit
8523abf957
276 changed files with 1401 additions and 5422 deletions
|
@ -12,9 +12,6 @@ namespace RimWorldAnimationStudio
|
|||
public class KeyframeSlider : Slider, IPointerClickHandler, IBeginDragHandler, IEndDragHandler
|
||||
{
|
||||
public AnimationTimeline timeline;
|
||||
//public AnimationClip clip;
|
||||
//public Keyframe keyframe;
|
||||
|
||||
public Transform ghostSliders;
|
||||
public Slider ghostSliderPrefab;
|
||||
public int maxGhosts = 4;
|
||||
|
@ -22,18 +19,22 @@ namespace RimWorldAnimationStudio
|
|||
public int actorID;
|
||||
public int keyframeID;
|
||||
|
||||
private PawnAnimationClip clip;
|
||||
private PawnKeyframe keyframe;
|
||||
|
||||
public void Initialize(AnimationTimeline timeline, int actorID, int keyframeID)
|
||||
{
|
||||
this.timeline = timeline;
|
||||
//this.clip = clip;
|
||||
//this.keyframe = keyframe;
|
||||
this.clip = Workspace.Instance.GetPawnAnimationClip(actorID);
|
||||
this.keyframe = Workspace.Instance.GetPawnKeyframe(actorID, keyframeID);
|
||||
|
||||
this.actorID = actorID;
|
||||
this.keyframeID = keyframeID;
|
||||
|
||||
PawnKeyframe keyframe = Workspace.Instance.GetPawnKeyframe(actorID, keyframeID);
|
||||
Debug.Log(keyframe.atTick);
|
||||
value = (float)keyframe.atTick / Workspace.animationClipWindowSize;
|
||||
maxValue = Workspace.animationClipWindowSize;
|
||||
value = keyframe.atTick.Value;
|
||||
|
||||
OnValueChanged();
|
||||
|
||||
onValueChanged.AddListener(delegate (float value) { OnValueChanged(); });
|
||||
|
@ -41,12 +42,7 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
public void OnValueChanged()
|
||||
{
|
||||
PawnKeyframe keyframe = Workspace.Instance.GetPawnKeyframe(actorID, keyframeID);
|
||||
PawnAnimationClip clip = Workspace.Instance.GetPawnAnimationClip(actorID);
|
||||
|
||||
int newTick = Mathf.RoundToInt(value * Workspace.animationClipWindowSize);
|
||||
|
||||
keyframe.atTick = newTick;
|
||||
keyframe.atTick = (int)value;
|
||||
|
||||
UpdateGhostFrames();
|
||||
|
||||
|
@ -58,9 +54,6 @@ namespace RimWorldAnimationStudio
|
|||
// Ghost sliders are non-interactable slider handle
|
||||
public void UpdateGhostFrames()
|
||||
{
|
||||
PawnKeyframe keyframe = Workspace.Instance.GetPawnKeyframe(actorID, keyframeID);
|
||||
PawnAnimationClip clip = Workspace.Instance.GetPawnAnimationClip(actorID);
|
||||
|
||||
if (maxGhosts == 0)
|
||||
{ return; }
|
||||
|
||||
|
@ -79,7 +72,7 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
Slider ghostSlider = ghostSliderObject.GetComponent<Slider>();
|
||||
Debug.Log(ghostSlider);
|
||||
ghostSlider.value = (float)((i + 1) * clip.duration + keyframe.atTick) / Workspace.animationClipWindowSize;
|
||||
ghostSlider.value = (int)((i + 1) * clip.duration + keyframe.atTick);
|
||||
|
||||
float mult = 1f - Mathf.Pow((float)i / maxGhosts, 2);
|
||||
ghostSlider.transform.FindDeepChild("Handle").GetComponent<Image>().color = new Color(0, 0.5f, 0.5f, 0.5f * mult);
|
||||
|
@ -92,8 +85,6 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
public int GetGhostFramesRequired()
|
||||
{
|
||||
PawnAnimationClip clip = Workspace.Instance.GetPawnAnimationClip(actorID);
|
||||
|
||||
if (Workspace.animationDef.animationStages[Workspace.stageID].isLooping == false)
|
||||
{ return 0; }
|
||||
|
||||
|
@ -105,31 +96,48 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
PawnKeyframe keyframe = Workspace.Instance.GetPawnKeyframe(actorID, keyframeID);
|
||||
|
||||
foreach (KeyframeSlider keyframeSlider in timeline.transform.GetComponentsInChildren<KeyframeSlider>())
|
||||
{
|
||||
if (keyframeSlider == this)
|
||||
{ continue; }
|
||||
|
||||
keyframeSlider.transform.FindDeepChild("Handle").GetComponent<Image>().color = new Color(1f, 1f, 1f);
|
||||
}
|
||||
|
||||
transform.FindDeepChild("Handle").GetComponent<Image>().color = new Color(0f, 1f, 0f);
|
||||
|
||||
AnimationController.Instance.stageTick = keyframe.atTick.Value;
|
||||
|
||||
Workspace.keyframeID = keyframeID;
|
||||
Activate();
|
||||
}
|
||||
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
Activate();
|
||||
|
||||
if (keyframe.atTick == 1)
|
||||
{ return; }
|
||||
|
||||
interactable = true;
|
||||
}
|
||||
|
||||
public override void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
base.OnDrag(eventData);
|
||||
|
||||
Activate();
|
||||
}
|
||||
|
||||
public void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
interactable = false;
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
AnimationController.Instance.stageTick = keyframe.atTick.Value;
|
||||
|
||||
Workspace.keyframeID = keyframeID;
|
||||
|
||||
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
|
||||
{ keyframeSlider.transform.FindDeepChild("Handle").GetComponent<Image>().color = new Color(1f, 1f, 1f); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue