mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Code refactor
This commit is contained in:
parent
a55ba7b95b
commit
5ca7e486f8
243 changed files with 1065 additions and 625 deletions
|
@ -11,45 +11,50 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
public class AnimationTimeline : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
public int actorID;
|
||||
public int actorID = -1;
|
||||
public KeyframeSlider keyframeSliderPrefab;
|
||||
|
||||
private Transform anchorTransform;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
EventsManager.onAnimationTimelinesChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onKeyframeCountChanged.AddListener(delegate { UpdateGUI(); });
|
||||
EventsManager.onActorIDChanged.AddListener(delegate { UpdateTimelineSelection(); });
|
||||
|
||||
UpdateTimelineSelection();
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void Initialize(int actorID)
|
||||
{
|
||||
anchorTransform = transform.parent;
|
||||
this.actorID = actorID;
|
||||
|
||||
UpdateGUI();
|
||||
}
|
||||
|
||||
public void UpdateGUI()
|
||||
{
|
||||
if (actorID < 0) return;
|
||||
|
||||
PawnAnimationClip clip = Workspace.GetPawnAnimationClip(actorID);
|
||||
if (clip == null) return;
|
||||
|
||||
clip.BuildSimpleCurves();
|
||||
|
||||
foreach (KeyframeSlider slider in GetComponentsInChildren<KeyframeSlider>())
|
||||
{ RemovePawnKeyFrame(slider.keyframeID);}
|
||||
{ RemovePawnKeyFrame(slider.keyframeID); }
|
||||
|
||||
foreach (PawnKeyframe keyframe in clip.Keyframes)
|
||||
{ AddPawnKeyFrame(keyframe.keyframeID); }
|
||||
|
||||
/*int keyframeCount = clip.keyframes.Count;
|
||||
int childCount = GetComponentsInChildren<KeyframeSlider>().Count();
|
||||
InitiateUpdateOfGhostFrames();
|
||||
}
|
||||
|
||||
for (int i = 0; i < Mathf.Max(keyframeCount, childCount); i++)
|
||||
{
|
||||
// Add new keyframe sliders as required
|
||||
if (i >= childCount)
|
||||
{ AddPawnKeyFrame(clip.keyframes[i].keyframeID); }
|
||||
|
||||
// Get objects to update
|
||||
KeyframeSlider keyframeSlider = GetComponentsInChildren<KeyframeSlider>()[i];
|
||||
|
||||
// Update values
|
||||
if (i < keyframeCount)
|
||||
{ keyframeSlider.Initialize(this, actorID, clip.keyframes[i].keyframeID); }
|
||||
|
||||
// Remove excess objects as required
|
||||
else
|
||||
{ RemovePawnKeyFrame(GetComponentsInChildren<KeyframeSlider>()[i].keyframeID); }
|
||||
}*/
|
||||
public void UpdateTimelineSelection()
|
||||
{
|
||||
GetComponent<Image>().color = (Workspace.ActorID == actorID ? Constants.ColorGoldYellow : Constants.ColorMidGrey);
|
||||
}
|
||||
|
||||
public void AddPawnKeyFrame(int keyframeID)
|
||||
|
@ -64,19 +69,8 @@ namespace RimWorldAnimationStudio
|
|||
Destroy(keyframeSlider?.gameObject);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (Workspace.ActorID == actorID)
|
||||
{ GetComponent<Image>().color = Constants.ColorGoldYellow; }
|
||||
|
||||
else
|
||||
{ GetComponent<Image>().color = Constants.ColorMidGrey; }
|
||||
}
|
||||
|
||||
public void InitiateUpdateOfGhostFrames()
|
||||
{
|
||||
//if (AnimationController.Instance.IsTimelineDirty()) return;
|
||||
|
||||
BroadcastMessage("UpdateGhostFrames");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue