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,9 +11,6 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
public class AnimationController : Singleton<AnimationController>
|
||||
{
|
||||
[Header("Animation settings")]
|
||||
public bool isAnimating = false;
|
||||
|
||||
[Header("Object references")]
|
||||
public Transform animationTimelines;
|
||||
public Transform actorBodies;
|
||||
|
@ -40,7 +37,7 @@ namespace RimWorldAnimationStudio
|
|||
if (Workspace.animationDef == null) return;
|
||||
|
||||
// Update stage tick / loop count if animating
|
||||
if (isAnimating)
|
||||
if (Workspace.IsAnimating)
|
||||
{
|
||||
timeSinceLastUpdate += Time.deltaTime;
|
||||
|
||||
|
@ -50,54 +47,54 @@ namespace RimWorldAnimationStudio
|
|||
timeSinceLastUpdate -= 1 / (playBackSpeed * 60f);
|
||||
Workspace.StageTick += 1;
|
||||
|
||||
if (Workspace.StageTick > Workspace.StageWindowSize)
|
||||
if (Workspace.StageTick >= Workspace.StageWindowSize)
|
||||
{
|
||||
switch (stageLoopDropdown.value)
|
||||
{
|
||||
case 1: Workspace.StageTick = Constants.minTick; break;
|
||||
case 2: UpdateLoopCount(Workspace.GetCurrentAnimationStage().StageLoopsNormal); break;
|
||||
case 3: UpdateLoopCount(Workspace.GetCurrentAnimationStage().StageLoopsQuick); break;
|
||||
default: break;
|
||||
default: Workspace.IsAnimating = false; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update animation preview
|
||||
UpdateAnimationPReview();
|
||||
UpdateAnimationPreview();
|
||||
}
|
||||
|
||||
public void UpdateLoopCount(int stageLoops)
|
||||
{
|
||||
++loopCount;
|
||||
loopCount++;
|
||||
Workspace.StageTick = Constants.minTick;
|
||||
|
||||
if (loopCount >= stageLoops)
|
||||
{
|
||||
++Workspace.StageID;
|
||||
loopCount = 0;
|
||||
}
|
||||
if (Workspace.StageID >= Workspace.animationDef.AnimationStages.Count - 1)
|
||||
{ Workspace.IsAnimating = false; }
|
||||
|
||||
if (Workspace.StageID >= Workspace.animationDef.AnimationStages.Count - 1)
|
||||
{
|
||||
Workspace.StageTick = Workspace.StageWindowSize;
|
||||
Workspace.isAnimating = false;
|
||||
else
|
||||
{
|
||||
Workspace.StageID++;
|
||||
loopCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateAnimationPReview()
|
||||
public void UpdateAnimationPreview()
|
||||
{
|
||||
if (Workspace.animationDef == null || Workspace.StageID >= Workspace.animationDef?.AnimationStages.Count) return;
|
||||
|
||||
List<ActorBody> actorBodiesList = actorBodies.GetComponentsInChildren<ActorBody>().ToList();
|
||||
|
||||
for (int actorID = 0; actorID < actorBodiesList.Count; actorID++)
|
||||
for (int actorID = 0; actorID < Workspace.animationDef.actors.Count; actorID++)
|
||||
{
|
||||
// Get the current actor and their animation clip
|
||||
Actor actor = Workspace.GetActor(actorID);
|
||||
PawnAnimationClip clip = Workspace.GetPawnAnimationClip(actorID);
|
||||
|
||||
// Get flags
|
||||
bool quiver = isAnimating && Workspace.GetCurrentOrPreviousKeyframe(actorID).Quiver == true;
|
||||
bool quiver = Workspace.IsAnimating && Workspace.GetCurrentOrPreviousKeyframe(actorID).Quiver == true;
|
||||
bool requiresGenitals = actor.RequiredGenitals.Any(x => x == "Penis") || actor.IsFucking;
|
||||
|
||||
// Get clip percentage
|
||||
|
@ -193,9 +190,6 @@ namespace RimWorldAnimationStudio
|
|||
{
|
||||
Debug.Log("Initializing animation preview");
|
||||
|
||||
foreach (Transform child in transform)
|
||||
{ child.gameObject.SetActive(true); }
|
||||
|
||||
int actorCount = Workspace.animationDef.Actors.Count;
|
||||
int childCount = animationTimelines.GetComponentsInChildren<AnimationTimeline>().Count();
|
||||
|
||||
|
@ -227,15 +221,17 @@ namespace RimWorldAnimationStudio
|
|||
}
|
||||
}
|
||||
|
||||
foreach (AnimationTimeline timeline in animationTimelines.GetComponentsInChildren<AnimationTimeline>())
|
||||
{ timeline.InitiateUpdateOfGhostFrames(); }
|
||||
EventsManager.OnAnimationTimelinesChanged();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
Workspace.isAnimating = false;
|
||||
Workspace.IsAnimating = false;
|
||||
timeSinceLastUpdate = 0;
|
||||
loopCount = 0;
|
||||
|
||||
foreach (Transform child in transform)
|
||||
{ child.gameObject.SetActive(true); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue