mirror of
https://gitgud.io/AbstractConcept/rimworld-animation-studio.git
synced 2024-08-15 00:43:27 +00:00
Bug fixes plus better layout
This commit is contained in:
parent
b0a965e0b2
commit
18c0473f39
192 changed files with 4773 additions and 5746 deletions
|
@ -24,7 +24,8 @@ namespace RimWorldAnimationStudio
|
|||
public InputField animationClipTimeField;
|
||||
public InputField animationClipLengthField;
|
||||
public ActorCard actorCard;
|
||||
public Transform animationTimelines;
|
||||
public Transform animationTimelines;
|
||||
public Transform actorBodies;
|
||||
|
||||
[Header("Prefabs")]
|
||||
public ActorBody actorBodyPrefab;
|
||||
|
@ -110,9 +111,9 @@ namespace RimWorldAnimationStudio
|
|||
InitializeAnimationTimeline();
|
||||
}
|
||||
|
||||
List<ActorBody> actorBodies = GetComponentsInChildren<ActorBody>().ToList();
|
||||
List<ActorBody> _actorBodies = actorBodies.GetComponentsInChildren<ActorBody>().ToList();
|
||||
|
||||
for (int actorID = 0; actorID < actorBodies.Count; actorID++)
|
||||
for (int actorID = 0; actorID < _actorBodies.Count; actorID++)
|
||||
{
|
||||
if (Workspace.stageID >= Workspace.animationDef?.animationStages.Count)
|
||||
{ Debug.Log("Waiting for animation stage data to initialize..."); return; }
|
||||
|
@ -127,7 +128,7 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
float clipPercent = (float)(stageTick % clip.duration) / clip.duration;
|
||||
|
||||
ActorBody actorBody = actorBodies[actorID];
|
||||
ActorBody actorBody = _actorBodies[actorID];
|
||||
string bodyType = actorBody.bodyType;
|
||||
|
||||
Vector3 deltaPos = new Vector3(clip.BodyOffsetX.Evaluate(clipPercent), 0, clip.BodyOffsetZ.Evaluate(clipPercent));
|
||||
|
@ -161,13 +162,17 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
actorBody.bodyRenderer.sortingLayerName = clip.layer;
|
||||
actorBody.headRenderer.sortingLayerName = clip.layer;
|
||||
actorBody.headRenderer.sortingOrder = headFacing == 0 ? -1 : 1;
|
||||
actorBody.headRenderer.sortingOrder = bodyFacing == 0 ? -1 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
Debug.Log("Initializing animation preview");
|
||||
|
||||
foreach (Transform child in transform)
|
||||
{ child.gameObject.SetActive(true); }
|
||||
|
||||
Reset();
|
||||
|
||||
InitializeAnimationTimeline();
|
||||
|
@ -183,7 +188,7 @@ namespace RimWorldAnimationStudio
|
|||
|
||||
for (int actorID = 0; actorID < Workspace.animationDef.actors.Count; actorID++)
|
||||
{
|
||||
ActorBody actorBody = Instantiate(actorBodyPrefab, transform);
|
||||
ActorBody actorBody = Instantiate(actorBodyPrefab, actorBodies.transform);
|
||||
actorBody.Initialize(actorID);
|
||||
|
||||
AnimationTimeline animationTimeline = Instantiate(animationTimelinePrefab, animationTimelines);
|
||||
|
@ -212,65 +217,13 @@ namespace RimWorldAnimationStudio
|
|||
timeSinceLastUpdate = 0;
|
||||
cycleIndex = 0;
|
||||
|
||||
foreach (ActorBody actorBody in GetComponentsInChildren<ActorBody>())
|
||||
foreach (ActorBody actorBody in actorBodies.GetComponentsInChildren<ActorBody>())
|
||||
{ Destroy(actorBody.gameObject); }
|
||||
|
||||
foreach (AnimationTimeline animationTimeline in animationTimelines.GetComponentsInChildren<AnimationTimeline>())
|
||||
{ Destroy(animationTimeline.gameObject); }
|
||||
}
|
||||
|
||||
public bool AddAnimationStage()
|
||||
{
|
||||
AnimationStage stage = new AnimationStage();
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
|
||||
return stage.MakeNew();
|
||||
}
|
||||
|
||||
public bool CloneAnimationStage()
|
||||
{
|
||||
AnimationStage stage = Workspace.animationDef.animationStages[Workspace.stageID].Copy();
|
||||
stage.Initialize();
|
||||
stage.stageName += " (Clone)";
|
||||
|
||||
Workspace.animationDef.animationStages.Insert(Workspace.stageID + 1, stage);
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool MoveAnimationStage(int startIndex, int delta)
|
||||
{
|
||||
if (startIndex + delta < 0 || startIndex + delta >= Workspace.animationDef.animationStages.Count)
|
||||
{ return false; }
|
||||
|
||||
AnimationStage stage = Workspace.animationDef.animationStages[startIndex];
|
||||
Workspace.animationDef.animationStages[startIndex] = Workspace.animationDef.animationStages[startIndex + delta];
|
||||
Workspace.animationDef.animationStages[startIndex + delta] = stage;
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool RemoveAnimationStage()
|
||||
{
|
||||
if (Workspace.animationDef.animationStages.Count == 1)
|
||||
{
|
||||
Debug.LogWarning("Cannot delete animation stage - the animation must contain at least one animation stage.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Workspace.animationDef.animationStages.RemoveAt(Workspace.stageID);
|
||||
Workspace.stageID = Workspace.stageID >= Workspace.animationDef.animationStages.Count ? Workspace.stageID = Workspace.animationDef.animationStages.Count - 1 : Workspace.stageID;
|
||||
|
||||
Workspace.Instance.MakeDirty();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void AddActor()
|
||||
{
|
||||
Actor actor = new Actor();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue