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
cd4711a8e5
commit
757badf4f6
517 changed files with 2534 additions and 2221 deletions
|
@ -28,19 +28,19 @@ namespace RimWorldAnimationStudio
|
|||
private int dragTickStart = -1;
|
||||
|
||||
public KeyframeSlider linkedSlider;
|
||||
public Keyframe pivotKeyframe;
|
||||
public PawnKeyframe pivotKeyframe;
|
||||
public int linkedOffset;
|
||||
|
||||
public void Initialize(AnimationTimeline timeline, int actorID, int keyframeID)
|
||||
{
|
||||
this.timeline = timeline;
|
||||
this.clip = Workspace.Instance.GetPawnAnimationClip(actorID);
|
||||
this.keyframe = Workspace.Instance.GetPawnKeyframe(actorID, keyframeID);
|
||||
this.clip = Workspace.GetPawnAnimationClip(actorID);
|
||||
this.keyframe = Workspace.GetPawnKeyframe(actorID, keyframeID);
|
||||
|
||||
this.actorID = actorID;
|
||||
this.keyframeID = keyframeID;
|
||||
|
||||
PawnKeyframe keyframe = Workspace.Instance.GetPawnKeyframe(actorID, keyframeID);
|
||||
PawnKeyframe keyframe = Workspace.GetPawnKeyframe(actorID, keyframeID);
|
||||
maxValue = Workspace.StageWindowSize;
|
||||
value = keyframe.atTick.Value;
|
||||
|
||||
|
@ -85,7 +85,7 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
public int GetGhostFramesRequired()
|
||||
{
|
||||
if (Workspace.animationDef.animationStages[Workspace.stageID].isLooping == false)
|
||||
if (Workspace.animationDef.AnimationStages[Workspace.StageID].IsLooping == false)
|
||||
{ return 0; }
|
||||
|
||||
if (clip.duration <= 1)
|
||||
|
@ -96,7 +96,7 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
Workspace.actorID = actorID;
|
||||
Workspace.ActorID = actorID;
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.LeftCommand))
|
||||
{ Workspace.keyframeID.Add(keyframeID); }
|
||||
|
@ -105,19 +105,19 @@ namespace RimWorldAnimationStudio
|
|||
{ Workspace.keyframeID = new List<int> { keyframeID }; }
|
||||
|
||||
if (eventData.clickCount >= 2)
|
||||
{ AnimationController.Instance.stageTick = keyframe.atTick.Value; }
|
||||
{ Workspace.StageTick = keyframe.atTick.Value; }
|
||||
}
|
||||
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
Workspace.actorID = actorID;
|
||||
Workspace.ActorID = actorID;
|
||||
dragTimeStart = Time.unscaledTime;
|
||||
dragTickStart = keyframe.atTick.Value;
|
||||
|
||||
if (Workspace.keyframeID.NullOrEmpty() || Workspace.keyframeID.Contains(keyframeID) == false)
|
||||
{ Workspace.keyframeID = new List<int> { keyframeID }; }
|
||||
|
||||
List<PawnKeyframe> selectedKeyframes = Workspace.Instance.GetPawnKeyframesByID(Workspace.keyframeID).Except(new List<PawnKeyframe>() { keyframe })?.ToList();
|
||||
List<PawnKeyframe> selectedKeyframes = Workspace.GetPawnKeyframesByID(Workspace.keyframeID).Except(new List<PawnKeyframe>() { keyframe })?.ToList();
|
||||
|
||||
// Link other slected keyframes to the movement of this one
|
||||
if (selectedKeyframes.NotNullOrEmpty())
|
||||
|
@ -143,7 +143,7 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
public override void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
Workspace.actorID = actorID;
|
||||
Workspace.ActorID = actorID;
|
||||
|
||||
// The first keyframe can't be moved
|
||||
if (keyframe.atTick == Constants.minTick)
|
||||
|
@ -157,7 +157,7 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
// Snap to nearest keyframe (on another timeline)
|
||||
int targetTick = Workspace.FindClosestKeyFrameAtTick(keyframe.atTick.Value, Mathf.CeilToInt(Workspace.StageWindowSize * 0.01f), actorID);
|
||||
if (Input.GetKey(KeyCode.LeftShift) && Workspace.Instance.DoesPawnKeyframeExistAtTick(Workspace.stageID, actorID, targetTick) == false)
|
||||
if (Input.GetKey(KeyCode.LeftShift) && Workspace.DoesPawnKeyframeExistAtTick(Workspace.StageID, actorID, targetTick) == false)
|
||||
{ value = (float)targetTick; }
|
||||
|
||||
// Prevent other frames from being moved to the first keyframe
|
||||
|
@ -170,13 +170,13 @@ namespace RimWorldAnimationStudio
|
|||
if (keyframe.atTick == Constants.minTick)
|
||||
{ value = Constants.minTick; return; }
|
||||
|
||||
List<PawnKeyframe> keyframesToCheck = Workspace.Instance.GetPawnKeyframesAtTick(actorID, keyframe.atTick.Value);
|
||||
List<PawnKeyframe> keyframesToCheck = Workspace.GetAllPawnKeyframesAtTick(actorID, keyframe.atTick.Value);
|
||||
if (keyframesToCheck.NotNullOrEmpty())
|
||||
{
|
||||
foreach (PawnKeyframe _keyframe in keyframesToCheck)
|
||||
{
|
||||
if (_keyframe != keyframe)
|
||||
{ AnimationController.Instance.RemovePawnKeyframe(actorID, _keyframe.keyframeID); }
|
||||
{ Workspace.GetCurrentPawnAnimationClip().RemovePawnKeyframe(actorID, _keyframe.keyframeID); }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,14 +189,14 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
if (linkedSlider.linkedSlider != null)
|
||||
{
|
||||
keyframesToCheck = Workspace.Instance.GetPawnKeyframesAtTick(actorID, linkedKeyframe.atTick.Value);
|
||||
keyframesToCheck = Workspace.GetAllPawnKeyframesAtTick(actorID, linkedKeyframe.atTick.Value);
|
||||
|
||||
if (keyframesToCheck.NotNullOrEmpty() && keyframesToCheck.Count > 1)
|
||||
{
|
||||
foreach (PawnKeyframe _keyframe in keyframesToCheck)
|
||||
{
|
||||
if (_keyframe.keyframeID != linkedKeyframe.keyframeID)
|
||||
{ AnimationController.Instance.RemovePawnKeyframe(actorID, _keyframe.keyframeID); Debug.Log("delete"); }
|
||||
{ Workspace.GetCurrentPawnAnimationClip().RemovePawnKeyframe(actorID, _keyframe.keyframeID); Debug.Log("delete"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
interactable = false;
|
||||
|
||||
Workspace.Instance.RecordEvent("Keyframe move");
|
||||
Workspace.RecordEvent("Keyframe move");
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
|
@ -229,20 +229,20 @@ namespace RimWorldAnimationStudio
|
|||
{ value = keyframe.atTick.Value; }
|
||||
|
||||
// Update key color
|
||||
if (keyframe.atTick.HasValue && Workspace.keyframeID.Contains(keyframeID) && AnimationController.Instance.stageTick == keyframe.atTick.Value)
|
||||
if (keyframe.atTick.HasValue && Workspace.keyframeID.Contains(keyframeID) && Workspace.StageTick == keyframe.atTick.Value)
|
||||
{ handleImage.color = Constants.ColorPurple; }
|
||||
|
||||
else if (Workspace.keyframeID.Contains(keyframeID))
|
||||
{ handleImage.color = Constants.ColorCyan; }
|
||||
|
||||
else if (AnimationController.Instance.stageTick == keyframe.atTick.Value)
|
||||
else if (Workspace.StageTick == keyframe.atTick.Value)
|
||||
{ handleImage.color = Constants.ColorPink; }
|
||||
|
||||
else
|
||||
{ handleImage.color = Constants.ColorGrey; }
|
||||
|
||||
// Show sound symbol
|
||||
string soundDef = Workspace.Instance.GetPawnKeyframe(actorID, keyframeID)?.soundEffect;
|
||||
string soundDef = Workspace.GetPawnKeyframe(actorID, keyframeID)?.SoundEffect;
|
||||
soundIcon.SetActive(soundDef != null && soundDef != "" && soundDef != "None");
|
||||
}
|
||||
|
||||
|
@ -253,7 +253,7 @@ namespace RimWorldAnimationStudio
|
|||
return (float)(keyframe.atTick.Value - pivotKeyframe.atTick.Value) / (dragTickStart - pivotKeyframe.atTick.Value);
|
||||
}
|
||||
|
||||
public bool IsPivotKeyframe(Keyframe otherKeyframe)
|
||||
public bool IsPivotKeyframe(PawnKeyframe otherKeyframe)
|
||||
{
|
||||
return pivotKeyframe == otherKeyframe;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue